82 lines
2.7 KiB
PHP
82 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace TorstenHettstedt\TimekeepingApi\Tests\Unit\Controller;
|
|
|
|
use Exception;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\ContainerInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use Slim\Psr7\Request;
|
|
use TorstenHettstedt\TimekeepingApi\Controller\NotDatabasesException;
|
|
use TorstenHettstedt\TimekeepingApi\Controller\WorkingHoursViewController;
|
|
|
|
class WorkingHoursViewControllerTest extends AbstractControllerTest
|
|
{
|
|
/**
|
|
* @throws Exception
|
|
* @throws \PHPUnit\Framework\MockObject\Exception
|
|
*/
|
|
protected function _before(): void
|
|
{
|
|
parent::_before();
|
|
$this->request = $this->makeEmpty(Request::class);
|
|
}
|
|
|
|
/**
|
|
* @throws NotDatabasesException
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws Exception
|
|
*/
|
|
public function testConstructWithNonDatabase(): void
|
|
{
|
|
$this->container = $this->makeEmpty(ContainerInterface::class, [
|
|
'has' => false
|
|
]);
|
|
$this->expectException(NotDatabasesException::class);
|
|
new WorkingHoursViewController($this->container);
|
|
}
|
|
|
|
/**
|
|
* @throws NotDatabasesException
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws Exception
|
|
*/
|
|
public function testBrowseMonthly(): void
|
|
{
|
|
$controller = new WorkingHoursViewController($this->container);
|
|
$response = $controller->browseMonthly($this->request, $this->response, []);
|
|
$this->assertEquals(self::FICTIONAL_STATUS_CODE, $response->getStatusCode());
|
|
$this->assertNotEmpty($response->getBody()->getContents());
|
|
}
|
|
|
|
/**
|
|
* @throws NotDatabasesException
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws Exception
|
|
*/
|
|
public function testBrowseYearly(): void
|
|
{
|
|
$controller = new WorkingHoursViewController($this->container);
|
|
$response = $controller->browseYearly($this->request, $this->response, []);
|
|
$this->assertEquals(self::FICTIONAL_STATUS_CODE, $response->getStatusCode());
|
|
$this->assertNotEmpty($response->getBody()->getContents());
|
|
}
|
|
|
|
/**
|
|
* @throws NotDatabasesException
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
* @throws Exception
|
|
*/
|
|
public function testBrowseWeekly(): void
|
|
{
|
|
$controller = new WorkingHoursViewController($this->container);
|
|
$response = $controller->browseWeekly($this->request, $this->response, []);
|
|
$this->assertEquals(self::FICTIONAL_STATUS_CODE, $response->getStatusCode());
|
|
$this->assertNotEmpty($response->getBody()->getContents());
|
|
}
|
|
}
|