added team permissions (#996)
This commit is contained in:
44
tests/Repository/Query/ActivityFormTypeQueryTest.php
Normal file
44
tests/Repository/Query/ActivityFormTypeQueryTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
45
tests/Repository/Query/CustomerFormTypeQueryTest.php
Normal file
45
tests/Repository/Query/CustomerFormTypeQueryTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
51
tests/Repository/Query/ProjectFormTypeQueryTest.php
Normal file
51
tests/Repository/Query/ProjectFormTypeQueryTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
34
tests/Repository/Query/UserFormTypeQueryTest.php
Normal file
34
tests/Repository/Query/UserFormTypeQueryTest.php
Normal 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());
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,10 @@
|
||||
|
||||
namespace App\Tests\Repository;
|
||||
|
||||
use App\Entity\User;
|
||||
use App\Repository\TimesheetRepository;
|
||||
use App\Repository\WidgetRepository;
|
||||
use App\Security\CurrentUser;
|
||||
use App\Tests\Mocks\Security\CurrentUserFactory;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
@@ -22,7 +23,7 @@ class WidgetRepositoryTest extends TestCase
|
||||
public function testHasWidget()
|
||||
{
|
||||
$repoMock = $this->getMockBuilder(TimesheetRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = $this->getMockBuilder(CurrentUser::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = (new CurrentUserFactory($this))->create(new User());
|
||||
|
||||
$sut = new WidgetRepository($repoMock, $userMock, ['test' => []]);
|
||||
|
||||
@@ -37,7 +38,7 @@ class WidgetRepositoryTest extends TestCase
|
||||
public function testGetWidgetThrowsExceptionOnNonExistingWidget()
|
||||
{
|
||||
$repoMock = $this->getMockBuilder(TimesheetRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = $this->getMockBuilder(CurrentUser::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = (new CurrentUserFactory($this))->create(new User());
|
||||
|
||||
$sut = new WidgetRepository($repoMock, $userMock, ['test' => []]);
|
||||
$sut->get('foo');
|
||||
@@ -50,7 +51,7 @@ class WidgetRepositoryTest extends TestCase
|
||||
public function testGetWidgetThrowsExceptionOnInvalidType()
|
||||
{
|
||||
$repoMock = $this->getMockBuilder(TimesheetRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = $this->getMockBuilder(CurrentUser::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = (new CurrentUserFactory($this))->create(new User());
|
||||
|
||||
$sut = new WidgetRepository($repoMock, $userMock, ['test' => ['type' => 'FooBar', 'user' => false]]);
|
||||
$sut->get('test');
|
||||
@@ -63,7 +64,7 @@ class WidgetRepositoryTest extends TestCase
|
||||
public function testGetWidgetTriggersExceptionOnWrongClass()
|
||||
{
|
||||
$repoMock = $this->getMockBuilder(TimesheetRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = $this->getMockBuilder(CurrentUser::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = (new CurrentUserFactory($this))->create(new User());
|
||||
|
||||
$sut = new WidgetRepository($repoMock, $userMock, ['test' => ['type' => 'CompoundChart', 'user' => false]]);
|
||||
$sut->get('test');
|
||||
@@ -77,7 +78,7 @@ class WidgetRepositoryTest extends TestCase
|
||||
$repoMock = $this->getMockBuilder(TimesheetRepository::class)->disableOriginalConstructor()->getMock();
|
||||
$repoMock->method('getStatistic')->willReturn($data);
|
||||
|
||||
$userMock = $this->getMockBuilder(CurrentUser::class)->disableOriginalConstructor()->getMock();
|
||||
$userMock = (new CurrentUserFactory($this))->create(new User());
|
||||
|
||||
$widget = [
|
||||
'color' => 'sunny',
|
||||
|
||||
Reference in New Issue
Block a user