Files
kimai2/tests/Model/Statistic/YearTest.php

49 lines
1.3 KiB
PHP

<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Tests\Model\Statistic;
use App\Model\Statistic\Month;
use App\Model\Statistic\Year;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Model\Statistic\Year
*/
class YearTest extends TestCase
{
public function testDefaultValues()
{
$sut = new Year('1999');
self::assertNull($sut->getMonth(1));
self::assertEmpty($sut->getMonths());
self::assertIsArray($sut->getMonths());
self::assertEquals('1999', $sut->getYear());
}
public function testSetter()
{
$sut = new Year('1999');
$sut->setMonth(new Month('01'));
$sut->setMonth(new Month('02'));
$sut->setMonth(new Month('03'));
self::assertEquals(3, \count($sut->getMonths()));
$sut->setMonth(new Month('01'));
self::assertEquals(3, \count($sut->getMonths()));
self::assertInstanceOf(Month::class, $sut->getMonth(1));
self::assertInstanceOf(Month::class, $sut->getMonth(2));
self::assertInstanceOf(Month::class, $sut->getMonth(3));
self::assertNull($sut->getMonth(4));
}
}