Files
kimai2/tests/Controller/TimesheetControllerTest.php

78 lines
2.2 KiB
PHP

<?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\Controller;
use App\Entity\User;
use App\Tests\DataFixtures\TimesheetFixtures;
/**
* @coversDefaultClass \App\Controller\TimesheetController
* @group integration
* @group legacy
*/
class TimesheetControllerTest extends ControllerBaseTest
{
public function testIsSecure()
{
$this->assertUrlIsSecured('/timesheet/');
}
public function testIndexAction()
{
$client = $this->getClientForAuthenticatedUser();
$this->request($client, '/timesheet/');
$this->assertTrue($client->getResponse()->isSuccessful());
$this->assertHasDataTable($client);
}
public function testCreateAction()
{
$client = $this->getClientForAuthenticatedUser();
$this->request($client, '/timesheet/create');
$this->assertTrue($client->getResponse()->isSuccessful());
// TODO more tests
}
public function testCreateActionWithFromAndToValues()
{
$client = $this->getClientForAuthenticatedUser();
$this->request($client, '/timesheet/create?from=2018-08-02T20%3A00%3A00&to=2018-08-02T20%3A30%3A00');
$this->assertTrue($client->getResponse()->isSuccessful());
// TODO more tests
}
public function testEditAction()
{
$client = $this->getClientForAuthenticatedUser();
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$fixture = new TimesheetFixtures();
$fixture->setAmount(10);
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
$fixture->setStartDate('2017-05-01');
$this->importFixture($em, $fixture);
$this->request($client, '/timesheet/1/edit');
$response = $client->getResponse();
$docuUrl = $this->createUrl('/help/timesheet');
$this->assertTrue($response->isSuccessful());
$this->assertContains(
'<a href="'.$docuUrl.'"><i class="far fa-question-circle"></i></a>',
$response->getContent(),
'Could not find link to documentation'
);
// TODO more tests
}
}