added hourly and money budgets to activity, project and customer (#843)
This commit is contained in:
@@ -223,7 +223,7 @@ class ActivityControllerTest extends APIControllerBaseTest
|
||||
$expectedKeys = ['id', 'name', 'visible', 'project', 'hourlyRate', 'fixedRate', 'color'];
|
||||
|
||||
if ($full) {
|
||||
$expectedKeys = array_merge($expectedKeys, ['comment']);
|
||||
$expectedKeys = array_merge($expectedKeys, ['comment', 'budget', 'timeBudget']);
|
||||
}
|
||||
|
||||
$actual = array_keys($result);
|
||||
|
||||
@@ -167,7 +167,8 @@ class CustomerControllerTest extends APIControllerBaseTest
|
||||
|
||||
if ($full) {
|
||||
$expectedKeys = array_merge($expectedKeys, [
|
||||
'homepage', 'number', 'comment', 'company', 'contact', 'address', 'country', 'currency', 'phone', 'fax', 'mobile', 'email', 'timezone'
|
||||
'homepage', 'number', 'comment', 'company', 'contact', 'address', 'country', 'currency',
|
||||
'phone', 'fax', 'mobile', 'email', 'timezone', 'budget', 'timeBudget'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,6 @@ class ProjectControllerTest extends APIControllerBaseTest
|
||||
'name' => 'foo',
|
||||
'customer' => 1,
|
||||
'visible' => true,
|
||||
'budget' => 0,
|
||||
];
|
||||
$this->request($client, '/api/projects', 'POST', [], json_encode($data));
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
@@ -219,7 +218,7 @@ class ProjectControllerTest extends APIControllerBaseTest
|
||||
if ($full) {
|
||||
$expectedKeys = array_merge(
|
||||
$expectedKeys,
|
||||
['comment', 'budget', 'orderNumber']
|
||||
['comment', 'budget', 'timeBudget', 'orderNumber']
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Tests\DataFixtures\ActivityFixtures;
|
||||
use App\Tests\DataFixtures\ProjectFixtures;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@@ -33,6 +35,23 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
$this->assertHasDataTable($client);
|
||||
}
|
||||
|
||||
public function testBudgetAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setActivities($em->getRepository(Activity::class)->findAll());
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_ADMIN));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/activity/1/budget');
|
||||
self::assertHasProgressbar($client);
|
||||
}
|
||||
|
||||
public function testCreateAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
@@ -62,6 +81,7 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new ProjectFixtures();
|
||||
$fixture->setAmount(10);
|
||||
@@ -158,6 +178,7 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
@@ -197,6 +218,7 @@ class ActivityControllerTest extends ControllerBaseTest
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_USER));
|
||||
|
||||
@@ -103,12 +103,12 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
$response = $client->getResponse();
|
||||
self::assertInstanceOf(RedirectResponse::class, $response);
|
||||
|
||||
$this->assertTrue(
|
||||
self::assertTrue(
|
||||
$response->isRedirect(),
|
||||
sprintf('The secure URL %s is not protected.', $url)
|
||||
);
|
||||
|
||||
$this->assertStringEndsWith(
|
||||
self::assertStringEndsWith(
|
||||
'/login',
|
||||
$response->getTargetUrl(),
|
||||
sprintf('The secure URL %s does not redirect to the login form.', $url)
|
||||
@@ -134,7 +134,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser($role);
|
||||
$client->request($method, $this->createUrl($url));
|
||||
$this->assertFalse(
|
||||
self::assertFalse(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
sprintf('The secure URL %s is not protected for role %s', $url, $role)
|
||||
);
|
||||
@@ -143,11 +143,11 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
|
||||
protected function assertAccessDenied(Client $client)
|
||||
{
|
||||
$this->assertFalse(
|
||||
self::assertFalse(
|
||||
$client->getResponse()->isSuccessful(),
|
||||
'Access is not denied for URL: ' . $client->getRequest()->getUri()
|
||||
);
|
||||
$this->assertContains(
|
||||
self::assertContains(
|
||||
'Symfony\Component\Security\Core\Exception\AccessDeniedException',
|
||||
$client->getResponse()->getContent(),
|
||||
'Could not find AccessDeniedException in response'
|
||||
@@ -157,18 +157,18 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertAccessIsGranted(Client $client, string $url, string $method = 'GET', array $parameters = [])
|
||||
{
|
||||
$this->request($client, $url, $method, $parameters);
|
||||
$this->assertTrue($client->getResponse()->isSuccessful());
|
||||
self::assertTrue($client->getResponse()->isSuccessful());
|
||||
}
|
||||
|
||||
protected function assertRouteNotFound(Client $client)
|
||||
{
|
||||
$this->assertFalse($client->getResponse()->isSuccessful());
|
||||
$this->assertEquals(404, $client->getResponse()->getStatusCode());
|
||||
self::assertFalse($client->getResponse()->isSuccessful());
|
||||
self::assertEquals(404, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
protected function assertMainContentClass(Client $client, string $classname)
|
||||
{
|
||||
$this->assertContains('<section class="content ' . $classname . '">', $client->getResponse()->getContent());
|
||||
self::assertContains('<section class="content ' . $classname . '">', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +176,18 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
*/
|
||||
protected function assertHasDataTable(Client $client)
|
||||
{
|
||||
$this->assertContains('<table class="table table-striped table-hover dataTable" role="grid" data-reload-event="', $client->getResponse()->getContent());
|
||||
self::assertContains('<table class="table table-striped table-hover dataTable" role="grid" data-reload-event="', $client->getResponse()->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Client $client
|
||||
*/
|
||||
protected static function assertHasProgressbar(Client $client)
|
||||
{
|
||||
$content = $client->getResponse()->getContent();
|
||||
self::assertContains('<div class="progress-bar progress-bar-', $content);
|
||||
self::assertContains('" role="progressbar" aria-valuenow="', $content);
|
||||
self::assertContains('" aria-valuemin="0" aria-valuemax="100" style="width: ', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +198,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertDataTableRowCount(Client $client, string $id, int $count)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('section.content div#' . $id . ' table.table-striped tbody tr');
|
||||
$this->assertEquals($count, $node->count());
|
||||
self::assertEquals($count, $node->count());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,13 +208,13 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertPageActions(Client $client, array $buttons)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('section.content-header div.breadcrumb div.box-tools div.btn-group a.btn');
|
||||
$this->assertEquals(count($buttons), $node->count());
|
||||
self::assertEquals(count($buttons), $node->count());
|
||||
|
||||
foreach ($node->getIterator() as $element) {
|
||||
$expectedClass = str_replace('btn btn-default btn-', '', $element->getAttribute('class'));
|
||||
$this->assertArrayHasKey($expectedClass, $buttons);
|
||||
self::assertArrayHasKey($expectedClass, $buttons);
|
||||
$expectedUrl = $buttons[$expectedClass];
|
||||
$this->assertEquals($expectedUrl, $element->getAttribute('href'));
|
||||
self::assertEquals($expectedUrl, $element->getAttribute('href'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +239,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
$submittedForm = $result->filter($formSelector);
|
||||
$validationErrors = $submittedForm->filter('li.text-danger');
|
||||
|
||||
$this->assertEquals(
|
||||
self::assertEquals(
|
||||
count($fieldNames),
|
||||
count($validationErrors),
|
||||
sprintf('Expected %s validation errors, found %s', count($fieldNames), count($validationErrors))
|
||||
@@ -236,15 +247,15 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
|
||||
foreach ($fieldNames as $name) {
|
||||
$field = $submittedForm->filter($name);
|
||||
$this->assertNotNull($field, 'Could not find form field: ' . $name);
|
||||
self::assertNotNull($field, 'Could not find form field: ' . $name);
|
||||
$list = $field->nextAll();
|
||||
$this->assertNotNull($list, 'Form field has no validation message: ' . $name);
|
||||
self::assertNotNull($list, 'Form field has no validation message: ' . $name);
|
||||
|
||||
$validation = $list->filter('li.text-danger');
|
||||
if (count($validation) < 1) {
|
||||
// decorated form fields with icon have a different html structure, see kimai-theme.html.twig
|
||||
$classes = $field->parents()->getNode(1)->getAttribute('class');
|
||||
$this->assertContains('has-error', $classes, 'Form field has no validation message: ' . $name);
|
||||
self::assertContains('has-error', $classes, 'Form field has no validation message: ' . $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +275,7 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertCalloutWidgetWithMessage(Client $client, string $message)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('div.callout.callout-warning.lead');
|
||||
$this->assertContains($message, $node->text());
|
||||
self::assertContains($message, $node->text());
|
||||
}
|
||||
|
||||
protected function assertHasFlashDeleteSuccess(Client $client)
|
||||
@@ -284,9 +295,9 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertHasFlashSuccess(Client $client, string $message = null)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('div.alert.alert-success.alert-dismissible');
|
||||
$this->assertNotEmpty($node->text());
|
||||
self::assertNotEmpty($node->text());
|
||||
if (null !== $message) {
|
||||
$this->assertContains($message, $node->text());
|
||||
self::assertContains($message, $node->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,9 +308,9 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
protected function assertHasFlashError(Client $client, string $message = null)
|
||||
{
|
||||
$node = $client->getCrawler()->filter('div.alert.alert-error.alert-dismissible');
|
||||
$this->assertNotEmpty($node->text());
|
||||
self::assertNotEmpty($node->text());
|
||||
if (null !== $message) {
|
||||
$this->assertContains($message, $node->text());
|
||||
self::assertContains($message, $node->text());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,12 +320,12 @@ abstract class ControllerBaseTest extends WebTestCase
|
||||
*/
|
||||
protected function assertIsRedirect(Client $client, $url = null)
|
||||
{
|
||||
$this->assertTrue($client->getResponse()->isRedirect());
|
||||
self::assertTrue($client->getResponse()->isRedirect());
|
||||
if (null === $url) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->assertTrue($client->getResponse()->headers->has('Location'));
|
||||
$this->assertStringEndsWith($url, $client->getResponse()->headers->get('Location'));
|
||||
self::assertTrue($client->getResponse()->headers->has('Location'));
|
||||
self::assertStringEndsWith($url, $client->getResponse()->headers->get('Location'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Tests\DataFixtures\CustomerFixtures;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@@ -32,6 +34,23 @@ class CustomerControllerTest extends ControllerBaseTest
|
||||
$this->assertHasDataTable($client);
|
||||
}
|
||||
|
||||
public function testBudgetAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setProjects($em->getRepository(Project::class)->findAll());
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_ADMIN));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/customer/1/budget');
|
||||
self::assertHasProgressbar($client);
|
||||
}
|
||||
|
||||
public function testCreateAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use App\Tests\DataFixtures\CustomerFixtures;
|
||||
use App\Tests\DataFixtures\ProjectFixtures;
|
||||
use App\Tests\DataFixtures\TimesheetFixtures;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* @group integration
|
||||
@@ -33,6 +35,23 @@ class ProjectControllerTest extends ControllerBaseTest
|
||||
$this->assertHasDataTable($client);
|
||||
}
|
||||
|
||||
public function testBudgetAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
/** @var EntityManager $em */
|
||||
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
|
||||
|
||||
$fixture = new TimesheetFixtures();
|
||||
$fixture->setAmount(10);
|
||||
$fixture->setProjects($em->getRepository(Project::class)->findAll());
|
||||
$fixture->setUser($this->getUserByRole($em, User::ROLE_ADMIN));
|
||||
$this->importFixture($em, $fixture);
|
||||
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/project/1/budget');
|
||||
self::assertHasProgressbar($client);
|
||||
}
|
||||
|
||||
public function testCreateAction()
|
||||
{
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_ADMIN);
|
||||
|
||||
@@ -210,6 +210,6 @@ class UserControllerTest extends ControllerBaseTest
|
||||
$client = $this->getClientForAuthenticatedUser(User::ROLE_SUPER_ADMIN);
|
||||
$this->assertAccessIsGranted($client, '/admin/user/permissions');
|
||||
$this->assertHasDataTable($client);
|
||||
$this->assertDataTableRowCount($client, 'datatable_user_admin_permissions', 66);
|
||||
$this->assertDataTableRowCount($client, 'datatable_user_admin_permissions', 69);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ class TimesheetFixtures extends Fixture
|
||||
* @var Activity[]
|
||||
*/
|
||||
protected $activities = [];
|
||||
/**
|
||||
* @var Project[]
|
||||
*/
|
||||
protected $projects = [];
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -172,6 +176,17 @@ class TimesheetFixtures extends Fixture
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Project[] $projects
|
||||
* @return $this
|
||||
*/
|
||||
public function setProjects(array $projects)
|
||||
{
|
||||
$this->projects = $projects;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $useTags
|
||||
* @return TimesheetFixtures
|
||||
@@ -204,7 +219,10 @@ class TimesheetFixtures extends Fixture
|
||||
$activities = $this->getAllActivities($manager);
|
||||
}
|
||||
|
||||
$projects = $this->getAllProjects($manager);
|
||||
$projects = $this->projects;
|
||||
if (empty($projects)) {
|
||||
$projects = $this->getAllProjects($manager);
|
||||
}
|
||||
|
||||
$faker = Factory::create();
|
||||
$user = $this->user;
|
||||
|
||||
@@ -14,12 +14,12 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Platforms\MySqlPlatform;
|
||||
use Doctrine\DBAL\Platforms\SqlitePlatform;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Doctrine\UTCDateTimeType
|
||||
*/
|
||||
class UTCDateTimeTypeTest extends KernelTestCase
|
||||
class UTCDateTimeTypeTest extends TestCase
|
||||
{
|
||||
public function testGetUtc()
|
||||
{
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Activity
|
||||
*/
|
||||
class ActivityTest extends AbstractEntityTest
|
||||
class ActivityTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
@@ -28,6 +29,8 @@ class ActivityTest extends AbstractEntityTest
|
||||
$this->assertNull($sut->getFixedRate());
|
||||
$this->assertNull($sut->getHourlyRate());
|
||||
$this->assertNull($sut->getColor());
|
||||
$this->assertEquals(0.0, $sut->getBudget());
|
||||
$this->assertEquals(0, $sut->getTimeBudget());
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
@@ -48,7 +51,14 @@ class ActivityTest extends AbstractEntityTest
|
||||
|
||||
$this->assertInstanceOf(Activity::class, $sut->setFixedRate(13.47));
|
||||
$this->assertEquals(13.47, $sut->getFixedRate());
|
||||
|
||||
$this->assertInstanceOf(Activity::class, $sut->setHourlyRate(99));
|
||||
$this->assertEquals(99, $sut->getHourlyRate());
|
||||
|
||||
$this->assertInstanceOf(Activity::class, $sut->setBudget(12345.67));
|
||||
$this->assertEquals(12345.67, $sut->getBudget());
|
||||
|
||||
$this->assertInstanceOf(Activity::class, $sut->setTimeBudget(937321));
|
||||
$this->assertEquals(937321, $sut->getTimeBudget());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Configuration;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Configuration
|
||||
*/
|
||||
class ConfigurationTest extends AbstractEntityTest
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Customer
|
||||
*/
|
||||
class CustomerTest extends AbstractEntityTest
|
||||
class CustomerTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
@@ -43,6 +44,8 @@ class CustomerTest extends AbstractEntityTest
|
||||
$this->assertNull($sut->getFixedRate());
|
||||
$this->assertNull($sut->getHourlyRate());
|
||||
$this->assertNull($sut->getColor());
|
||||
$this->assertEquals(0.0, $sut->getBudget());
|
||||
$this->assertEquals(0, $sut->getTimeBudget());
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
@@ -84,7 +87,14 @@ class CustomerTest extends AbstractEntityTest
|
||||
|
||||
$this->assertInstanceOf(Customer::class, $sut->setFixedRate(13.47));
|
||||
$this->assertEquals(13.47, $sut->getFixedRate());
|
||||
|
||||
$this->assertInstanceOf(Customer::class, $sut->setHourlyRate(99));
|
||||
$this->assertEquals(99, $sut->getHourlyRate());
|
||||
|
||||
$this->assertInstanceOf(Customer::class, $sut->setBudget(12345.67));
|
||||
$this->assertEquals(12345.67, $sut->getBudget());
|
||||
|
||||
$this->assertInstanceOf(Customer::class, $sut->setTimeBudget(937321));
|
||||
$this->assertEquals(937321, $sut->getTimeBudget());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,13 +9,12 @@
|
||||
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Timesheet
|
||||
* Classes using this MUST extend \Symfony\Bundle\FrameworkBundle\Test\KernelTestCase
|
||||
*/
|
||||
abstract class AbstractEntityTest extends KernelTestCase
|
||||
trait EntityValidationTestTrait
|
||||
{
|
||||
/**
|
||||
* @param object $entity
|
||||
@@ -10,11 +10,12 @@
|
||||
namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\InvoiceTemplate;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\InvoiceTemplate
|
||||
*/
|
||||
class InvoiceTemplateTest extends AbstractEntityTest
|
||||
class InvoiceTemplateTest extends TestCase
|
||||
{
|
||||
protected function assertIsFluent($actual)
|
||||
{
|
||||
|
||||
@@ -11,11 +11,12 @@ namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Project
|
||||
*/
|
||||
class ProjectTest extends AbstractEntityTest
|
||||
class ProjectTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
@@ -26,7 +27,6 @@ class ProjectTest extends AbstractEntityTest
|
||||
$this->assertNull($sut->getOrderNumber());
|
||||
$this->assertNull($sut->getComment());
|
||||
$this->assertTrue($sut->getVisible());
|
||||
$this->assertEquals(0.0, $sut->getBudget());
|
||||
$this->assertNull($sut->getFixedRate());
|
||||
$this->assertNull($sut->getHourlyRate());
|
||||
self::assertIsIterable($sut->getTimesheets());
|
||||
@@ -34,6 +34,8 @@ class ProjectTest extends AbstractEntityTest
|
||||
self::assertIsIterable($sut->getActivities());
|
||||
self::assertEmpty($sut->getActivities());
|
||||
$this->assertNull($sut->getColor());
|
||||
$this->assertEquals(0.0, $sut->getBudget());
|
||||
$this->assertEquals(0, $sut->getTimeBudget());
|
||||
}
|
||||
|
||||
public function testSetterAndGetter()
|
||||
@@ -59,12 +61,16 @@ class ProjectTest extends AbstractEntityTest
|
||||
$this->assertInstanceOf(Project::class, $sut->setVisible(false));
|
||||
$this->assertFalse($sut->getVisible());
|
||||
|
||||
$this->assertInstanceOf(Project::class, $sut->setFixedRate(13.47));
|
||||
$this->assertEquals(13.47, $sut->getFixedRate());
|
||||
|
||||
$this->assertInstanceOf(Project::class, $sut->setHourlyRate(99));
|
||||
$this->assertEquals(99, $sut->getHourlyRate());
|
||||
|
||||
$this->assertInstanceOf(Project::class, $sut->setBudget(12345.67));
|
||||
$this->assertEquals(12345.67, $sut->getBudget());
|
||||
|
||||
$this->assertInstanceOf(Project::class, $sut->setFixedRate(13.47));
|
||||
$this->assertEquals(13.47, $sut->getFixedRate());
|
||||
$this->assertInstanceOf(Project::class, $sut->setHourlyRate(99));
|
||||
$this->assertEquals(99, $sut->getHourlyRate());
|
||||
$this->assertInstanceOf(Project::class, $sut->setTimeBudget(937321));
|
||||
$this->assertEquals(937321, $sut->getTimeBudget());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,12 @@ namespace App\Tests\Entity;
|
||||
|
||||
use App\Entity\Tag;
|
||||
use App\Entity\Timesheet;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Tag
|
||||
*/
|
||||
class TagTest extends AbstractEntityTest
|
||||
class TagTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
|
||||
@@ -16,11 +16,12 @@ use App\Entity\Tag;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Timesheet
|
||||
*/
|
||||
class TimesheetTest extends AbstractEntityTest
|
||||
class TimesheetTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
@@ -66,196 +67,6 @@ class TimesheetTest extends AbstractEntityTest
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public function testValidationNeedsActivity()
|
||||
{
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setProject(new Project())
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'activity');
|
||||
}
|
||||
|
||||
public function testValidationNeedsProject()
|
||||
{
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity(new Activity())
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationProjectMismatch()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$project2 = (new Project())->setName('bar')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project2)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationCustomerInvisible()
|
||||
{
|
||||
$customer = (new Customer())->setVisible(false);
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'customer');
|
||||
}
|
||||
|
||||
public function testValidationCustomerInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = (new Customer())->setVisible(false);
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationProjectInvisible()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer)->setVisible(false);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationProjectInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer)->setVisible(false);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationActivityInvisible()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'activity');
|
||||
}
|
||||
|
||||
public function testValidationActivityInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationEndNotEarlierThanBegin()
|
||||
{
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$end = $end->modify('-1 second');
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
|
||||
$this->assertHasViolationForField($entity, 'end');
|
||||
|
||||
// allow same begin and end
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
|
||||
$this->assertHasViolationForField($entity, []);
|
||||
}
|
||||
|
||||
public function testDurationMustBeGreatorOrEqualThanZero()
|
||||
{
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
$entity->setDuration(-1);
|
||||
|
||||
$this->assertHasViolationForField($entity, 'duration');
|
||||
|
||||
// allow zero duration
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
$entity->setDuration(0);
|
||||
|
||||
$this->assertHasViolationForField($entity, []);
|
||||
}
|
||||
|
||||
public function testTags()
|
||||
{
|
||||
$sut = new Timesheet();
|
||||
|
||||
237
tests/Entity/TimesheetValidationTest.php
Normal file
237
tests/Entity/TimesheetValidationTest.php
Normal file
@@ -0,0 +1,237 @@
|
||||
<?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\Entity;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Timesheet;
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\Timesheet
|
||||
* @group integration
|
||||
*/
|
||||
class TimesheetValidationTest extends KernelTestCase
|
||||
{
|
||||
use EntityValidationTestTrait;
|
||||
|
||||
protected function getEntity()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$customer->setName('Test Customer');
|
||||
|
||||
$project = new Project();
|
||||
$project->setName('Test Project');
|
||||
$project->setCustomer($customer);
|
||||
|
||||
$activity = new Activity();
|
||||
$activity->setName('Test');
|
||||
$activity->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity->setUser(new User());
|
||||
$entity->setActivity($activity);
|
||||
$entity->setProject($project);
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public function testValidationNeedsActivity()
|
||||
{
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setProject(new Project())
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'activity');
|
||||
}
|
||||
|
||||
public function testValidationNeedsProject()
|
||||
{
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity(new Activity())
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationProjectMismatch()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$project2 = (new Project())->setName('bar')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project2)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationCustomerInvisible()
|
||||
{
|
||||
$customer = (new Customer())->setVisible(false);
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'customer');
|
||||
}
|
||||
|
||||
public function testValidationCustomerInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = (new Customer())->setVisible(false);
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationProjectInvisible()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer)->setVisible(false);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'project');
|
||||
}
|
||||
|
||||
public function testValidationProjectInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer)->setVisible(false);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationActivityInvisible()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasViolationForField($entity, 'activity');
|
||||
}
|
||||
|
||||
public function testValidationActivityInvisibleDoesNotTriggerOnStoppedEntites()
|
||||
{
|
||||
$customer = new Customer();
|
||||
$project = (new Project())->setName('foo')->setCustomer($customer);
|
||||
$activity = (new Activity())->setName('hello-world')->setProject($project)->setVisible(false);
|
||||
|
||||
$entity = new Timesheet();
|
||||
$entity
|
||||
->setUser(new User())
|
||||
->setActivity($activity)
|
||||
->setProject($project)
|
||||
->setBegin(new \DateTime())
|
||||
->setEnd(new \DateTime())
|
||||
;
|
||||
|
||||
$this->assertHasNoViolations($entity);
|
||||
}
|
||||
|
||||
public function testValidationEndNotEarlierThanBegin()
|
||||
{
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$end = $end->modify('-1 second');
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
|
||||
$this->assertHasViolationForField($entity, 'end');
|
||||
|
||||
// allow same begin and end
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
|
||||
$this->assertHasViolationForField($entity, []);
|
||||
}
|
||||
|
||||
public function testDurationMustBeGreatorOrEqualThanZero()
|
||||
{
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
$entity->setDuration(-1);
|
||||
|
||||
$this->assertHasViolationForField($entity, 'duration');
|
||||
|
||||
// allow zero duration
|
||||
$entity = $this->getEntity();
|
||||
$begin = new \DateTime();
|
||||
$end = clone $begin;
|
||||
$entity->setBegin($begin);
|
||||
$entity->setEnd($end);
|
||||
$entity->setDuration(0);
|
||||
|
||||
$this->assertHasViolationForField($entity, []);
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,12 @@ namespace App\Tests\Entity;
|
||||
use App\Entity\User;
|
||||
use App\Entity\UserPreference;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\User
|
||||
*/
|
||||
class UserTest extends AbstractEntityTest
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
public function testDefaultValues()
|
||||
{
|
||||
@@ -40,60 +41,6 @@ class UserTest extends AbstractEntityTest
|
||||
$this->assertEquals('Mr. Code Blaster', $user->getTitle());
|
||||
}
|
||||
|
||||
public function getInvalidTestData()
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
[null, null],
|
||||
['xx', 'test@'], // too short username
|
||||
[str_pad('#', 61, '-'), 'test@x.'], // too long username
|
||||
[str_pad('#', 61, '-'), 'test@x.', ['xxxxx']], // too short password and invalid role
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestData
|
||||
*/
|
||||
public function testInvalidValues($username, $email, $roles = [])
|
||||
{
|
||||
$defaultFields = [
|
||||
'username', 'email'
|
||||
];
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($email);
|
||||
if (!empty($roles)) {
|
||||
$user->setRoles($roles);
|
||||
$defaultFields[] = 'roles';
|
||||
}
|
||||
|
||||
$this->assertHasViolationForField($user, $defaultFields);
|
||||
}
|
||||
|
||||
public function getValidTestData()
|
||||
{
|
||||
return [
|
||||
[str_pad('#', 3, '-'), 'test@x.x'], // shortest possible username
|
||||
[str_pad('#', 60, '-'), 'test@x.x', ['ROLE_TEAMLEAD']], // longest possible password and valid role
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestData
|
||||
*/
|
||||
public function testValidValues($username, $email, $roles = [])
|
||||
{
|
||||
$user = new User();
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($email);
|
||||
if (!empty($roles)) {
|
||||
$user->setRoles($roles);
|
||||
}
|
||||
|
||||
$this->assertHasNoViolations($user);
|
||||
}
|
||||
|
||||
public function testDatetime()
|
||||
{
|
||||
$date = new \DateTime('+1 day');
|
||||
|
||||
76
tests/Entity/UserValidationTest.php
Normal file
76
tests/Entity/UserValidationTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\Entity;
|
||||
|
||||
use App\Entity\User;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Entity\User
|
||||
* @group integration
|
||||
*/
|
||||
class UserValidationTest extends KernelTestCase
|
||||
{
|
||||
use EntityValidationTestTrait;
|
||||
|
||||
public function getInvalidTestData()
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
[null, null],
|
||||
['xx', 'test@'], // too short username
|
||||
[str_pad('#', 61, '-'), 'test@x.'], // too long username
|
||||
[str_pad('#', 61, '-'), 'test@x.', ['xxxxx']], // too short password and invalid role
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestData
|
||||
*/
|
||||
public function testInvalidValues($username, $email, $roles = [])
|
||||
{
|
||||
$defaultFields = [
|
||||
'username', 'email'
|
||||
];
|
||||
|
||||
$user = new User();
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($email);
|
||||
if (!empty($roles)) {
|
||||
$user->setRoles($roles);
|
||||
$defaultFields[] = 'roles';
|
||||
}
|
||||
|
||||
$this->assertHasViolationForField($user, $defaultFields);
|
||||
}
|
||||
|
||||
public function getValidTestData()
|
||||
{
|
||||
return [
|
||||
[str_pad('#', 3, '-'), 'test@x.x'], // shortest possible username
|
||||
[str_pad('#', 60, '-'), 'test@x.x', ['ROLE_TEAMLEAD']], // longest possible password and valid role
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestData
|
||||
*/
|
||||
public function testValidValues($username, $email, $roles = [])
|
||||
{
|
||||
$user = new User();
|
||||
$user->setUsername($username);
|
||||
$user->setEmail($email);
|
||||
if (!empty($roles)) {
|
||||
$user->setRoles($roles);
|
||||
}
|
||||
|
||||
$this->assertHasNoViolations($user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?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\Form\DataTransformer;
|
||||
|
||||
use App\Form\DataTransformer\DurationStringToSecondsTransformer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Form\DataTransformer\DurationStringToSecondsTransformer
|
||||
*/
|
||||
class DurationStringToSecondsTransformerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var DurationStringToSecondsTransformer
|
||||
*/
|
||||
private $sut;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->sut = new DurationStringToSecondsTransformer();
|
||||
}
|
||||
|
||||
public function getValidTestDataTransform()
|
||||
{
|
||||
return [
|
||||
['00:00', '0'],
|
||||
['00:00', 0],
|
||||
['02:00', 7213], // by default no seconds are returned
|
||||
[null, null],
|
||||
];
|
||||
}
|
||||
|
||||
public function getInvalidTestDataTransform()
|
||||
{
|
||||
return [
|
||||
[''],
|
||||
['xxx'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestDataTransform
|
||||
*/
|
||||
public function testTransform($expected, $transform)
|
||||
{
|
||||
$this->assertEquals($expected, $this->sut->transform($transform));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestDataTransform
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testInvalidTransformThrowsException($transform)
|
||||
{
|
||||
$this->sut->transform($transform);
|
||||
}
|
||||
|
||||
public function getValidTestDataReverseTransform()
|
||||
{
|
||||
return [
|
||||
['2h3s', 7203],
|
||||
['00:00', 0],
|
||||
['0', null],
|
||||
[null, null],
|
||||
];
|
||||
}
|
||||
|
||||
public function getInvalidTestDataReverseTransform()
|
||||
{
|
||||
return [
|
||||
['xxx'],
|
||||
[':::'],
|
||||
['0::0'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidTestDataReverseTransform
|
||||
*/
|
||||
public function testReverseTransform($transform, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, $this->sut->reverseTransform($transform));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidTestDataReverseTransform
|
||||
* @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
|
||||
*/
|
||||
public function testInvalidReverseTransformThrowsException($transform)
|
||||
{
|
||||
$this->sut->reverseTransform($transform);
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,19 @@ namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Invoice\Renderer\CsvRenderer;
|
||||
use App\Model\InvoiceModel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Renderer\CsvRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractSpreadsheetRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class CsvRendererTest extends AbstractRendererTest
|
||||
class CsvRendererTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(CsvRenderer::class);
|
||||
|
||||
@@ -11,10 +11,13 @@ namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Entity\InvoiceDocument;
|
||||
use App\Model\InvoiceModel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class DebugRendererTest extends AbstractRendererTest
|
||||
class DebugRendererTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function getTestModel()
|
||||
{
|
||||
yield [$this->getInvoiceModel(), '1,947.99', 5, 5, 1, 2, 2, true];
|
||||
|
||||
@@ -10,14 +10,18 @@
|
||||
namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Invoice\Renderer\DocxRenderer;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Renderer\DocxRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class DocxRendererTest extends AbstractRendererTest
|
||||
class DocxRendererTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(DocxRenderer::class);
|
||||
|
||||
@@ -11,15 +11,19 @@ namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Invoice\Renderer\OdsRenderer;
|
||||
use App\Model\InvoiceModel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Renderer\OdsRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractSpreadsheetRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class OdsRendererTest extends AbstractRendererTest
|
||||
class OdsRendererTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(OdsRenderer::class);
|
||||
|
||||
@@ -25,12 +25,11 @@ use App\Repository\Query\InvoiceQuery;
|
||||
use App\Twig\DateExtensions;
|
||||
use App\Twig\Extensions;
|
||||
use App\Utils\LocaleSettings;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
abstract class AbstractRendererTest extends KernelTestCase
|
||||
trait RendererTestTrait
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
@@ -10,15 +10,19 @@
|
||||
namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Invoice\Renderer\TwigRenderer;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Twig\Environment;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Renderer\TwigRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class TwigRendererTest extends AbstractRendererTest
|
||||
class TwigRendererTest extends KernelTestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$loader = new FilesystemLoader();
|
||||
|
||||
@@ -11,15 +11,19 @@ namespace App\Tests\Invoice\Renderer;
|
||||
|
||||
use App\Invoice\Renderer\XlsxRenderer;
|
||||
use App\Model\InvoiceModel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* @covers \App\Invoice\Renderer\XlsxRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractRenderer
|
||||
* @covers \App\Invoice\Renderer\AbstractSpreadsheetRenderer
|
||||
* @group integration
|
||||
*/
|
||||
class XlsxRendererTest extends AbstractRendererTest
|
||||
class XlsxRendererTest extends TestCase
|
||||
{
|
||||
use RendererTestTrait;
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$sut = $this->getAbstractRenderer(XlsxRenderer::class);
|
||||
|
||||
@@ -20,7 +20,6 @@ class ActivityStatisticTest extends TestCase
|
||||
public function testDefaultValues()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
$this->assertEquals(0, $sut->getCount());
|
||||
$this->assertEquals(0, $sut->getRecordAmount());
|
||||
$this->assertEquals(0, $sut->getRecordDuration());
|
||||
}
|
||||
@@ -28,11 +27,9 @@ class ActivityStatisticTest extends TestCase
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new ActivityStatistic();
|
||||
$sut->setCount(123);
|
||||
$sut->setRecordAmount(7654.298);
|
||||
$sut->setRecordDuration(826.10);
|
||||
|
||||
$this->assertEquals(123, $sut->getCount());
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ class CustomerStatisticTest extends TestCase
|
||||
$sut = new CustomerStatistic();
|
||||
$this->assertEquals(0, $sut->getActivityAmount());
|
||||
$this->assertEquals(0, $sut->getProjectAmount());
|
||||
$this->assertEquals(0, $sut->getCount());
|
||||
$this->assertEquals(0, $sut->getRecordAmount());
|
||||
$this->assertEquals(0, $sut->getRecordDuration());
|
||||
}
|
||||
@@ -30,7 +29,6 @@ class CustomerStatisticTest extends TestCase
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new CustomerStatistic();
|
||||
$sut->setCount(123);
|
||||
$sut->setRecordAmount(7654.298);
|
||||
$sut->setRecordDuration(826.10);
|
||||
$sut->setActivityAmount(13);
|
||||
@@ -38,7 +36,6 @@ class CustomerStatisticTest extends TestCase
|
||||
|
||||
$this->assertEquals(13, $sut->getActivityAmount());
|
||||
$this->assertEquals(2, $sut->getProjectAmount());
|
||||
$this->assertEquals(123, $sut->getCount());
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ class ProjectStatisticTest extends TestCase
|
||||
{
|
||||
$sut = new ProjectStatistic();
|
||||
$this->assertEquals(0, $sut->getActivityAmount());
|
||||
$this->assertEquals(0, $sut->getCount());
|
||||
$this->assertEquals(0, $sut->getRecordAmount());
|
||||
$this->assertEquals(0, $sut->getRecordDuration());
|
||||
}
|
||||
@@ -29,13 +28,11 @@ class ProjectStatisticTest extends TestCase
|
||||
public function testSetter()
|
||||
{
|
||||
$sut = new ProjectStatistic();
|
||||
$sut->setCount(123);
|
||||
$sut->setRecordAmount(7654.298);
|
||||
$sut->setRecordDuration(826.10);
|
||||
$sut->setActivityAmount(13);
|
||||
|
||||
$this->assertEquals(13, $sut->getActivityAmount());
|
||||
$this->assertEquals(123, $sut->getCount());
|
||||
$this->assertEquals(7654, $sut->getRecordAmount());
|
||||
$this->assertEquals(826, $sut->getRecordDuration());
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use App\Tests\DataFixtures\TagFixtures;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\TagRepository
|
||||
* @group integration
|
||||
*/
|
||||
class TagRepositoryTest extends AbstractRepositoryTest
|
||||
{
|
||||
|
||||
@@ -26,6 +26,7 @@ use Pagerfanta\Pagerfanta;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\TimesheetRepository
|
||||
* @group integration
|
||||
*/
|
||||
class TimesheetRepositoryTest extends AbstractRepositoryTest
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@ class DurationTest extends TestCase
|
||||
|
||||
[0, '', Duration::FORMAT_NATURAL],
|
||||
[0, 0, Duration::FORMAT_NATURAL],
|
||||
[99, '99s', Duration::FORMAT_NATURAL],
|
||||
[7200, '2h', Duration::FORMAT_NATURAL],
|
||||
[2280, '38m', Duration::FORMAT_NATURAL],
|
||||
[9480, '2h38m', Duration::FORMAT_NATURAL],
|
||||
@@ -65,6 +66,8 @@ class DurationTest extends TestCase
|
||||
[48420, '13:27', Duration::FORMAT_COLON],
|
||||
[48474, '13:27:54', Duration::FORMAT_COLON],
|
||||
[48474, '12:87:54', Duration::FORMAT_COLON],
|
||||
[11257200, '3127:00:00', Duration::FORMAT_COLON],
|
||||
[11257200, '3127:00', Duration::FORMAT_COLON],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -80,6 +83,14 @@ class DurationTest extends TestCase
|
||||
// invalid modes
|
||||
[17, 'foo'],
|
||||
[12, ''],
|
||||
|
||||
['3127::00', Duration::FORMAT_COLON],
|
||||
['00::', Duration::FORMAT_COLON],
|
||||
['3127:00:', Duration::FORMAT_COLON],
|
||||
[':3127:00', Duration::FORMAT_COLON],
|
||||
['::3127', Duration::FORMAT_COLON],
|
||||
['3127:-01', Duration::FORMAT_COLON],
|
||||
['-3127:01:17', Duration::FORMAT_COLON],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\MPdfConverter
|
||||
* @group integration
|
||||
*/
|
||||
class MPdfConverterTest extends KernelTestCase
|
||||
{
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
namespace App\Tests\Utils;
|
||||
|
||||
use App\Utils\MomentFormatConverter;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Utils\MomentFormatConverter
|
||||
*/
|
||||
class MomentFormatConverterTest extends KernelTestCase
|
||||
class MomentFormatConverterTest extends TestCase
|
||||
{
|
||||
public function test()
|
||||
{
|
||||
|
||||
102
tests/Validator/Constraints/DurationValidatorTest.php
Normal file
102
tests/Validator/Constraints/DurationValidatorTest.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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\Validator\Constraints;
|
||||
|
||||
use App\Validator\Constraints\Duration;
|
||||
use App\Validator\Constraints\DurationValidator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Regex;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
|
||||
/**
|
||||
* @covers \App\Validator\Constraints\DurationValidator
|
||||
*/
|
||||
class DurationValidatorTest extends ConstraintValidatorTestCase
|
||||
{
|
||||
protected function createValidator()
|
||||
{
|
||||
return new DurationValidator();
|
||||
}
|
||||
|
||||
public function getValidData()
|
||||
{
|
||||
return [
|
||||
['99s'],
|
||||
['2h'],
|
||||
['38m'],
|
||||
['2h38m'],
|
||||
['2h38m17s'],
|
||||
['1h96m137s'],
|
||||
[''],
|
||||
['0'],
|
||||
[null],
|
||||
[0],
|
||||
[11257200],
|
||||
['13:27'],
|
||||
['13:27:54'],
|
||||
['12:87:54'],
|
||||
['3127:00:00'],
|
||||
['3127:00'],
|
||||
[48474],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
|
||||
*/
|
||||
public function testConstraintIsInvalid()
|
||||
{
|
||||
$this->validator->validate('foo', new NotBlank());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getValidData
|
||||
* @param string $input
|
||||
*/
|
||||
public function testConstraintWithValidData($input)
|
||||
{
|
||||
$constraint = new Duration();
|
||||
$this->validator->validate($input, $constraint);
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function getInvalidData()
|
||||
{
|
||||
return [
|
||||
['13-13'],
|
||||
['13.13'],
|
||||
['3127::00'],
|
||||
['3127:00:'],
|
||||
[':3127:00'],
|
||||
['::3127'],
|
||||
['foo'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidData
|
||||
* @param mixed $input
|
||||
*/
|
||||
public function testValidationError($input)
|
||||
{
|
||||
$constraint = new Duration([
|
||||
'message' => 'myMessage',
|
||||
]);
|
||||
|
||||
$this->validator->validate($input, $constraint);
|
||||
|
||||
$expectedFormat = is_string($input) ? '"' . $input . '"' : $input;
|
||||
|
||||
$this->buildViolation('myMessage')
|
||||
->setParameter('{{ value }}', $expectedFormat)
|
||||
->setCode(Regex::REGEX_FAILED_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
}
|
||||
@@ -64,9 +64,9 @@ abstract class AbstractVoterTest extends TestCase
|
||||
protected function getRolePermissionManager(array $permissions = [], bool $overwrite = false)
|
||||
{
|
||||
if (!$overwrite) {
|
||||
$activities = ['view_activity', 'edit_activity', 'delete_activity', 'create_activity'];
|
||||
$projects = ['view_project', 'edit_project', 'delete_project', 'create_project'];
|
||||
$customers = ['view_customer', 'edit_customer', 'delete_customer', 'create_customer'];
|
||||
$activities = ['view_activity', 'edit_activity', 'budget_activity', 'delete_activity', 'create_activity'];
|
||||
$projects = ['view_project', 'edit_project', 'budget_project', 'delete_project', 'create_project'];
|
||||
$customers = ['view_customer', 'edit_customer', 'budget_customer', 'delete_customer', 'create_customer'];
|
||||
$invoice = ['view_invoice', 'create_invoice'];
|
||||
$invoiceTemplate = ['view_invoice_template', 'create_invoice_template', 'edit_invoice_template', 'delete_invoice_template'];
|
||||
$timesheet = ['view_own_timesheet', 'start_own_timesheet', 'stop_own_timesheet', 'create_own_timesheet', 'edit_own_timesheet', 'export_own_timesheet', 'delete_own_timesheet'];
|
||||
|
||||
@@ -43,6 +43,7 @@ class ActivityVoterTest extends AbstractVoterTest
|
||||
foreach ([$user3, $user4] as $user) {
|
||||
yield [$user, new Activity(), 'view', $result];
|
||||
yield [$user, new Activity(), 'edit', $result];
|
||||
yield [$user, new Activity(), 'budget', $result];
|
||||
yield [$user, new Activity(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ class ActivityVoterTest extends AbstractVoterTest
|
||||
foreach ([$user0, $user1, $user2] as $user) {
|
||||
yield [$user, new Activity(), 'view', $result];
|
||||
yield [$user, new Activity(), 'edit', $result];
|
||||
yield [$user, new Activity(), 'budget', $result];
|
||||
yield [$user, new Activity(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -57,6 +59,7 @@ class ActivityVoterTest extends AbstractVoterTest
|
||||
foreach ([$user0, $user1, $user2] as $user) {
|
||||
yield [$user, new Activity(), 'view_activity', $result];
|
||||
yield [$user, new Activity(), 'edit_activity', $result];
|
||||
yield [$user, new Activity(), 'budget_activity', $result];
|
||||
yield [$user, new Activity(), 'delete_activity', $result];
|
||||
yield [$user, new \stdClass(), 'view', $result];
|
||||
yield [$user, null, 'edit', $result];
|
||||
|
||||
@@ -43,6 +43,7 @@ class CustomerVoterTest extends AbstractVoterTest
|
||||
foreach ([$user3, $user4] as $user) {
|
||||
yield [$user, new Customer(), 'view', $result];
|
||||
yield [$user, new Customer(), 'edit', $result];
|
||||
yield [$user, new Customer(), 'budget', $result];
|
||||
yield [$user, new Customer(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ class CustomerVoterTest extends AbstractVoterTest
|
||||
foreach ([$user0, $user1, $user2] as $user) {
|
||||
yield [$user, new Customer(), 'view', $result];
|
||||
yield [$user, new Customer(), 'edit', $result];
|
||||
yield [$user, new Customer(), 'budget', $result];
|
||||
yield [$user, new Customer(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -57,6 +59,7 @@ class CustomerVoterTest extends AbstractVoterTest
|
||||
foreach ([$user0, $user1, $user2] as $user) {
|
||||
yield [$user, new Customer(), 'view_customer', $result];
|
||||
yield [$user, new Customer(), 'edit_customer', $result];
|
||||
yield [$user, new Customer(), 'budget_customer', $result];
|
||||
yield [$user, new Customer(), 'delete_customer', $result];
|
||||
yield [$user, new \stdClass(), 'view', $result];
|
||||
yield [$user, null, 'edit', $result];
|
||||
|
||||
@@ -43,6 +43,7 @@ class ProjectVoterTest extends AbstractVoterTest
|
||||
foreach ([$user3, $user4] as $user) {
|
||||
yield [$user, new Project(), 'view', $result];
|
||||
yield [$user, new Project(), 'edit', $result];
|
||||
yield [$user, new Project(), 'budget', $result];
|
||||
yield [$user, new Project(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -50,6 +51,7 @@ class ProjectVoterTest extends AbstractVoterTest
|
||||
foreach ([$user0, $user1, $user2] as $user) {
|
||||
yield [$user, new Project(), 'view', $result];
|
||||
yield [$user, new Project(), 'edit', $result];
|
||||
yield [$user, new Project(), 'budget', $result];
|
||||
yield [$user, new Project(), 'delete', $result];
|
||||
}
|
||||
|
||||
@@ -58,6 +60,7 @@ class ProjectVoterTest extends AbstractVoterTest
|
||||
yield [$user, new Project(), 'create_project', $result];
|
||||
yield [$user, new Project(), 'view_project', $result];
|
||||
yield [$user, new Project(), 'edit_project', $result];
|
||||
yield [$user, new Project(), 'budget_project', $result];
|
||||
yield [$user, new Project(), 'delete_project', $result];
|
||||
yield [$user, new \stdClass(), 'view', $result];
|
||||
yield [$user, null, 'edit', $result];
|
||||
|
||||
Reference in New Issue
Block a user