financial year setting + new users working time per year report (#2547)
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
namespace App\Tests\Model\Statistic;
|
||||
|
||||
use App\Model\Statistic\Month;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -29,32 +28,61 @@ class MonthTest extends TestCase
|
||||
self::assertSame(0.0, $sut->getBillableRate());
|
||||
}
|
||||
|
||||
public function testAllowedMonths()
|
||||
public function getTestData()
|
||||
{
|
||||
for ($i = 1; $i < 10; $i++) {
|
||||
new Month('0' . $i);
|
||||
}
|
||||
for ($i = 10; $i < 13; $i++) {
|
||||
new Month((string) $i);
|
||||
}
|
||||
self::assertTrue(true);
|
||||
yield ['01', '01', 1];
|
||||
yield ['02', '02', 2];
|
||||
yield ['03', '03', 3];
|
||||
yield ['04', '04', 4];
|
||||
yield ['05', '05', 5];
|
||||
yield ['06', '06', 6];
|
||||
yield ['07', '07', 7];
|
||||
yield ['08', '08', 8];
|
||||
yield ['09', '09', 9];
|
||||
yield ['10', '10', 10];
|
||||
yield ['11', '11', 11];
|
||||
yield ['12', '12', 12];
|
||||
yield [1, '01', 1];
|
||||
yield [2, '02', 2];
|
||||
yield [3, '03', 3];
|
||||
yield [4, '04', 4];
|
||||
yield [5, '05', 5];
|
||||
yield [6, '06', 6];
|
||||
yield [7, '07', 7];
|
||||
yield [8, '08', 8];
|
||||
yield [9, '09', 9];
|
||||
yield [10, '10', 10];
|
||||
yield [11, '11', 11];
|
||||
yield [12, '12', 12];
|
||||
}
|
||||
|
||||
public function testInvalidMonths()
|
||||
/**
|
||||
* @dataProvider getTestData
|
||||
*/
|
||||
public function testAllowedMonths($init, $month, $number)
|
||||
{
|
||||
foreach (['00', '13', '99', '0.9'] as $month) {
|
||||
$ex = null;
|
||||
try {
|
||||
new Month($month);
|
||||
} catch (Exception $e) {
|
||||
$ex = $e;
|
||||
}
|
||||
self::assertInstanceOf(InvalidArgumentException::class, $ex);
|
||||
self::assertEquals(
|
||||
'Invalid month given. Expected 1-12, received "' . ((int) $month) . '".',
|
||||
$ex->getMessage()
|
||||
);
|
||||
}
|
||||
$sut = new Month($init);
|
||||
self::assertEquals($month, $sut->getMonth());
|
||||
self::assertEquals($number, $sut->getMonthNumber());
|
||||
}
|
||||
|
||||
public function getInvalidTestData()
|
||||
{
|
||||
yield ['00'];
|
||||
yield ['13'];
|
||||
yield ['99'];
|
||||
yield ['0.9'];
|
||||
yield [19];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestData
|
||||
*/
|
||||
public function testInvalidMonths($month)
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Invalid month given. Expected 1-12, received "' . ((int) $month) . '".');
|
||||
new Month($month);
|
||||
}
|
||||
|
||||
public function testSetter()
|
||||
|
||||
Reference in New Issue
Block a user