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

@@ -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',