added team permissions (#996)

This commit is contained in:
Kevin Papst
2019-08-16 01:22:33 +02:00
committed by GitHub
parent 9611646bc6
commit 561ec3b1e9
124 changed files with 4122 additions and 362 deletions

View File

@@ -0,0 +1,44 @@
<?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\Repository\Query;
use App\Entity\Activity;
use App\Entity\Project;
use App\Repository\Query\ActivityFormTypeQuery;
/**
* @covers \App\Repository\Query\ActivityFormTypeQuery
*/
class ActivityFormTypeQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new ActivityFormTypeQuery();
self::assertTrue($sut->isGlobalsOnly());
$project = new Project();
self::assertNull($sut->getProject());
self::assertInstanceOf(ActivityFormTypeQuery::class, $sut->setProject($project));
self::assertSame($project, $sut->getProject());
$activity = new Activity();
self::assertNull($sut->getActivity());
self::assertInstanceOf(ActivityFormTypeQuery::class, $sut->setActivity($activity));
self::assertSame($activity, $sut->getActivity());
self::assertFalse($sut->isGlobalsOnly());
$activity = new Activity();
self::assertNull($sut->getActivityToIgnore());
self::assertInstanceOf(ActivityFormTypeQuery::class, $sut->setActivityToIgnore($activity));
self::assertSame($activity, $sut->getActivityToIgnore());
}
}

View File

@@ -9,6 +9,7 @@
namespace App\Tests\Repository\Query;
use App\Entity\Team;
use App\Repository\Query\BaseQuery;
use PHPUnit\Framework\TestCase;
@@ -29,6 +30,7 @@ class BaseQueryTest extends TestCase
$this->assertPageSize($sut);
$this->assertOrderBy($sut, $orderBy);
$this->assertOrder($sut);
$this->assertTeams($sut);
}
protected function assertResultType(BaseQuery $sut)
@@ -49,6 +51,14 @@ class BaseQueryTest extends TestCase
}
}
protected function assertTeams(BaseQuery $sut)
{
self::assertEmpty($sut->getTeams());
self::assertInstanceOf(BaseQuery::class, $sut->addTeam(new Team()));
self::assertEquals(1, count($sut->getTeams()));
}
protected function assertPage(BaseQuery $sut)
{
$this->assertEquals(BaseQuery::DEFAULT_PAGE, $sut->getPage());

View File

@@ -0,0 +1,45 @@
<?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\Repository\Query;
use App\Entity\Customer;
use App\Entity\Team;
use App\Entity\User;
use App\Repository\Query\CustomerFormTypeQuery;
/**
* @covers \App\Repository\Query\CustomerFormTypeQuery
*/
class CustomerFormTypeQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new CustomerFormTypeQuery();
self::assertEmpty($sut->getTeams());
self::assertInstanceOf(CustomerFormTypeQuery::class, $sut->addTeam(new Team()));
self::assertCount(1, $sut->getTeams());
$customer = new Customer();
self::assertNull($sut->getCustomer());
self::assertInstanceOf(CustomerFormTypeQuery::class, $sut->setCustomer($customer));
self::assertSame($customer, $sut->getCustomer());
$customer = new Customer();
self::assertNull($sut->getCustomerToIgnore());
self::assertInstanceOf(CustomerFormTypeQuery::class, $sut->setCustomerToIgnore($customer));
self::assertSame($customer, $sut->getCustomerToIgnore());
$user = new User();
self::assertNull($sut->getUser());
self::assertInstanceOf(CustomerFormTypeQuery::class, $sut->setUser($user));
self::assertSame($user, $sut->getUser());
}
}

View File

@@ -0,0 +1,51 @@
<?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\Repository\Query;
use App\Entity\Customer;
use App\Entity\Project;
use App\Entity\Team;
use App\Entity\User;
use App\Repository\Query\ProjectFormTypeQuery;
/**
* @covers \App\Repository\Query\ProjectFormTypeQuery
*/
class ProjectFormTypeQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new ProjectFormTypeQuery();
self::assertEmpty($sut->getTeams());
self::assertInstanceOf(ProjectFormTypeQuery::class, $sut->addTeam(new Team()));
self::assertCount(1, $sut->getTeams());
$project = new Project();
self::assertNull($sut->getProject());
self::assertInstanceOf(ProjectFormTypeQuery::class, $sut->setProject($project));
self::assertSame($project, $sut->getProject());
$project = new Project();
self::assertNull($sut->getProjectToIgnore());
self::assertInstanceOf(ProjectFormTypeQuery::class, $sut->setProjectToIgnore($project));
self::assertSame($project, $sut->getProjectToIgnore());
$customer = new Customer();
self::assertNull($sut->getCustomer());
self::assertInstanceOf(ProjectFormTypeQuery::class, $sut->setCustomer($customer));
self::assertSame($customer, $sut->getCustomer());
$user = new User();
self::assertNull($sut->getUser());
self::assertInstanceOf(ProjectFormTypeQuery::class, $sut->setUser($user));
self::assertSame($user, $sut->getUser());
}
}

View File

@@ -0,0 +1,34 @@
<?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\Repository\Query;
use App\Entity\Team;
use App\Entity\User;
use App\Repository\Query\UserFormTypeQuery;
/**
* @covers \App\Repository\Query\UserFormTypeQuery
*/
class UserFormTypeQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new UserFormTypeQuery();
self::assertEmpty($sut->getTeams());
self::assertInstanceOf(UserFormTypeQuery::class, $sut->addTeam(new Team()));
self::assertCount(1, $sut->getTeams());
$user = new User();
self::assertNull($sut->getUser());
self::assertInstanceOf(UserFormTypeQuery::class, $sut->setUser($user));
self::assertSame($user, $sut->getUser());
}
}