api-erstellen #1
@@ -6,8 +6,10 @@ use Codeception\Test\Unit;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use stdClass;
|
||||
use TorstenHettstedt\TimekeepingApi\Models\WorkingHours;
|
||||
use TorstenHettstedt\TimekeepingApi\Repositories\RepositoryModelAlreadyExists;
|
||||
use TorstenHettstedt\TimekeepingApi\Repositories\RepositoryRecordNotFoundException;
|
||||
@@ -58,6 +60,20 @@ class WorkingHoursRepositoryTest extends Unit
|
||||
$repository->findByKey(self::NEW_DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testInsertWithInvalidModel(): void
|
||||
{
|
||||
$repository = new WorkingHoursRepository($this->pdoObject);
|
||||
$model = $this->make(stdClass::class, [
|
||||
'workingDay' => new DateTime(self::NEW_DATE),
|
||||
'workingTime' => new DateInterval(self::NEW_INTERVAL),
|
||||
]);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$repository->insert($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
* @throws Exception
|
||||
@@ -91,6 +107,21 @@ class WorkingHoursRepositoryTest extends Unit
|
||||
$repository->insert($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testDeleteWithInvalidModel(): void
|
||||
{
|
||||
$repository = new WorkingHoursRepository($this->pdoObject);
|
||||
$model = $this->make(stdClass::class, [
|
||||
'workingDay' => new DateTime(self::EXISTING_DATE),
|
||||
'workingTime' => new DateInterval(self::EXISTING_INTERVAL),
|
||||
]);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$repository->delete($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
* @throws Exception
|
||||
@@ -118,6 +149,22 @@ class WorkingHoursRepositoryTest extends Unit
|
||||
$repository->delete($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testUpdateWithInvalidModel(): void
|
||||
{
|
||||
$repository = new WorkingHoursRepository($this->pdoObject);
|
||||
$model = $this->make(stdClass::class, [
|
||||
'workingDay' => new DateTime(self::EXISTING_DATE),
|
||||
'workingTime' => new DateInterval(self::NEW_INTERVAL),
|
||||
]);
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$repository->update($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
* @throws Exception
|
||||
|
||||
Reference in New Issue
Block a user