API improvements (#1826)

This commit is contained in:
Kevin Papst
2020-07-17 20:30:16 +02:00
committed by GitHub
parent 5864c7e127
commit c843dba29a
77 changed files with 1745 additions and 1189 deletions

View File

@@ -0,0 +1,32 @@
<?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\API\Model;
use App\API\Model\I18nConfig;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\API\Model\I18nConfig
*/
class I18nConfigTest extends TestCase
{
public function testSetter()
{
$sut = new I18nConfig();
$this->assertInstanceOf(I18nConfig::class, $sut->setIs24hours(false));
$this->assertInstanceOf(I18nConfig::class, $sut->setDuration('foo'));
$this->assertInstanceOf(I18nConfig::class, $sut->setDate('bar'));
$this->assertInstanceOf(I18nConfig::class, $sut->setDateTime('hello'));
$this->assertInstanceOf(I18nConfig::class, $sut->setFormDate('world'));
$this->assertInstanceOf(I18nConfig::class, $sut->setFormDateTime('testing'));
$this->assertInstanceOf(I18nConfig::class, $sut->setTime('fun'));
}
}

View File

@@ -1,52 +0,0 @@
<?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\API\Model;
use App\API\Model\I18n;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\API\Model\I18n
*/
class I18nTest extends TestCase
{
public function testDefaultValues()
{
$sut = new I18n();
$this->assertTrue($sut->isIs24hours());
$this->assertEquals('', $sut->getDuration());
$this->assertEquals('', $sut->getDate());
$this->assertEquals('', $sut->getDateTime());
$this->assertEquals('', $sut->getFormDate());
$this->assertEquals('', $sut->getFormDateTime());
$this->assertEquals('', $sut->getTime());
}
public function testSetter()
{
$sut = new I18n();
$this->assertInstanceOf(I18n::class, $sut->setIs24hours(false));
$this->assertInstanceOf(I18n::class, $sut->setDuration('foo'));
$this->assertInstanceOf(I18n::class, $sut->setDate('bar'));
$this->assertInstanceOf(I18n::class, $sut->setDateTime('hello'));
$this->assertInstanceOf(I18n::class, $sut->setFormDate('world'));
$this->assertInstanceOf(I18n::class, $sut->setFormDateTime('testing'));
$this->assertInstanceOf(I18n::class, $sut->setTime('fun'));
$this->assertFalse($sut->isIs24hours());
$this->assertEquals('foo', $sut->getDuration());
$this->assertEquals('bar', $sut->getDate());
$this->assertEquals('hello', $sut->getDateTime());
$this->assertEquals('world', $sut->getFormDate());
$this->assertEquals('testing', $sut->getFormDateTime());
$this->assertEquals('fun', $sut->getTime());
}
}

View File

@@ -17,17 +17,6 @@ use PHPUnit\Framework\TestCase;
*/
class TimesheetConfigTest extends TestCase
{
public function testDefaultValues()
{
$sut = new TimesheetConfig();
$this->assertTrue($sut->isAllowFutureTimes());
$this->assertTrue($sut->isAllowOverlapping());
$this->assertEquals('now', $sut->getDefaultBeginTime());
$this->assertEquals('default', $sut->getTrackingMode());
$this->assertEquals(1, $sut->getActiveEntriesSoftLimit());
$this->assertEquals(1, $sut->getActiveEntriesHardLimit());
}
public function testSetter()
{
$sut = new TimesheetConfig();
@@ -38,12 +27,5 @@ class TimesheetConfigTest extends TestCase
$this->assertInstanceOf(TimesheetConfig::class, $sut->setTrackingMode('punch'));
$this->assertInstanceOf(TimesheetConfig::class, $sut->setActiveEntriesSoftLimit(2));
$this->assertInstanceOf(TimesheetConfig::class, $sut->setActiveEntriesHardLimit(3));
$this->assertFalse($sut->isAllowFutureTimes());
$this->assertFalse($sut->isAllowOverlapping());
$this->assertEquals('08:00', $sut->getDefaultBeginTime());
$this->assertEquals('punch', $sut->getTrackingMode());
$this->assertEquals(2, $sut->getActiveEntriesSoftLimit());
$this->assertEquals(3, $sut->getActiveEntriesHardLimit());
}
}