api-erstellen #1
@@ -3,6 +3,8 @@
|
||||
namespace TorstenHettstedt\TimekeepingApi\Tests\Unit\Repositories;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use PDO;
|
||||
use TorstenHettstedt\TimekeepingApi\Models\WorkingHoursView;
|
||||
use TorstenHettstedt\TimekeepingApi\Repositories\RepositoryRecordNotFoundException;
|
||||
@@ -12,16 +14,11 @@ use TorstenHettstedt\TimekeepingApi\Repositories\WorkingHoursYearlyViewRepositor
|
||||
|
||||
class WorkingHoursViewRepositoryTest extends Unit
|
||||
{
|
||||
const EXISTING_DATE = '2020-01-28';
|
||||
const EXISTING_INTERVAL = 'PT7H20M';
|
||||
const NEW_DATE = '2020-04-01';
|
||||
const NEW_INTERVAL = 'PT7H59M';
|
||||
const RECORDS_COUNT = 61;
|
||||
|
||||
protected PDO $pdoObject;
|
||||
|
||||
protected function _before(): void
|
||||
{
|
||||
/** @noinspection SpellCheckingInspection */
|
||||
$this->pdoObject = new PDO('pgsql:host=psql.torsten-hettstedt.net;port=5432;dbname=testdb;user=bruce;password=mypass');
|
||||
parent::_before();
|
||||
}
|
||||
@@ -44,9 +41,9 @@ class WorkingHoursViewRepositoryTest extends Unit
|
||||
public function existingObjectProvider(): array
|
||||
{
|
||||
return [
|
||||
[WorkingHoursYearlyViewRepository::class, '2020', 61],
|
||||
[WorkingHoursMonthlyViewRepository::class, '2020 February', 20],
|
||||
[WorkingHoursWeeklyViewRepository::class, '2020#03', 5],
|
||||
[WorkingHoursYearlyViewRepository::class, '2020', 61, new DateTime('2020-01-01', new DateTimeZone('UCT'))],
|
||||
[WorkingHoursMonthlyViewRepository::class, '2020 February', 20, new DateTime('2020-02-01', new DateTimeZone('UCT'))],
|
||||
[WorkingHoursWeeklyViewRepository::class, '2020#03', 5, new DateTime('2020-01-13', new DateTimeZone('UCT'))],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -81,16 +78,18 @@ class WorkingHoursViewRepositoryTest extends Unit
|
||||
*
|
||||
* @dataProvider existingObjectProvider
|
||||
*
|
||||
* @param string $period_class
|
||||
* @param string $search
|
||||
* @param int $workingDays
|
||||
* @param string $period_class
|
||||
* @param string $search
|
||||
* @param int $workingDays
|
||||
* @param DateTime $period
|
||||
*/
|
||||
public function testExistingFindByKey(string $period_class, string $search, int $workingDays): void
|
||||
public function testExistingFindByKey(string $period_class, string $search, int $workingDays, DateTime $period): void
|
||||
{
|
||||
$repository = new $period_class($this->pdoObject);
|
||||
$model = $repository->findByKey($search);
|
||||
$this->assertInstanceOf(WorkingHoursView::class, $model);
|
||||
$this->assertEquals($workingDays, $model->getWorkingDays());
|
||||
$this->assertEquals($period->format('Ymd'), $model->getPeriod()->format('Ymd'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user