upgraded to symfony 4 #74 (#81)

This commit is contained in:
Kevin Papst
2018-01-12 20:39:07 +01:00
committed by GitHub
parent c011b83b73
commit a87355695e
232 changed files with 5260 additions and 4231 deletions

View File

@@ -0,0 +1,47 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\Repository\Query\ActivityQuery;
use App\Repository\Query\VisibilityQuery;
/**
* @covers \App\Repository\Query\ActivityQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ActivityQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new ActivityQuery();
$this->assertBaseQuery($sut);
$this->assertInstanceOf(VisibilityQuery::class, $sut);
$this->assertNull($sut->getCustomer());
$this->assertNull($sut->getProject());
$expected = new Customer();
$expected->setName('foo-bar');
$sut->setCustomer($expected);
$this->assertEquals($expected, $sut->getCustomer());
$expected = new Project();
$expected->setName('foo-bar');
$sut->setProject($expected);
$this->assertEquals($expected, $sut->getProject());
}
}

View File

@@ -0,0 +1,99 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\User;
use App\Repository\Query\BaseQuery;
use \PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Query\BaseQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class BaseQueryTest extends TestCase
{
public function testQuery()
{
$this->assertBaseQuery(new BaseQuery());
}
protected function assertBaseQuery(BaseQuery $sut)
{
$this->assertResultType($sut);
$this->assertHiddenEntity($sut);
$this->assertPage($sut);
$this->assertPageSize($sut);
$this->assertOrderBy($sut);
$this->assertOrder($sut);
}
protected function assertResultType(BaseQuery $sut)
{
$this->assertEquals(BaseQuery::RESULT_TYPE_PAGER, $sut->getResultType());
$sut->setResultType('foo-bar');
$this->assertEquals(BaseQuery::RESULT_TYPE_PAGER, $sut->getResultType());
$sut->setResultType(BaseQuery::RESULT_TYPE_QUERYBUILDER);
$this->assertEquals(BaseQuery::RESULT_TYPE_QUERYBUILDER, $sut->getResultType());
}
protected function assertHiddenEntity(BaseQuery $sut)
{
$this->assertNull($sut->getHiddenEntity());
$actual = new User();
$actual->setUsername('foo-bar');
$sut->setHiddenEntity($actual);
$this->assertEquals($actual, $sut->getHiddenEntity());
}
protected function assertPage(BaseQuery $sut)
{
$this->assertEquals(BaseQuery::DEFAULT_PAGE, $sut->getPage());
$sut->setPage(42);
$this->assertEquals(42, $sut->getPage());
}
protected function assertPageSize(BaseQuery $sut)
{
$this->assertEquals(BaseQuery::DEFAULT_PAGESIZE, $sut->getPageSize());
$sut->setPageSize(100);
$this->assertEquals(100, $sut->getPageSize());
}
protected function assertOrderBy(BaseQuery $sut, $column = 'id')
{
$this->assertEquals($column, $sut->getOrderBy());
$sut->setOrderBy('foo');
$this->assertEquals('foo', $sut->getOrderBy());
}
protected function assertOrder(BaseQuery $sut, $order = BaseQuery::ORDER_ASC)
{
$this->assertEquals($order, $sut->getOrder());
$sut->setOrder('foo');
$this->assertEquals($order, $sut->getOrder());
$sut->setOrder(BaseQuery::ORDER_ASC);
$this->assertEquals(BaseQuery::ORDER_ASC, $sut->getOrder());
$sut->setOrder(BaseQuery::ORDER_DESC);
$this->assertEquals(BaseQuery::ORDER_DESC, $sut->getOrder());
}
}

View File

@@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\Repository\Query\VisibilityQuery;
use App\Repository\Query\CustomerQuery;
/**
* @covers \App\Repository\Query\CustomerQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class CustomerQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new CustomerQuery();
$this->assertBaseQuery($sut);
$this->assertInstanceOf(VisibilityQuery::class, $sut);
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\Repository\Query\ProjectQuery;
use App\Repository\Query\VisibilityQuery;
/**
* @covers \App\Repository\Query\ProjectQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProjectQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new ProjectQuery();
$this->assertBaseQuery($sut);
$this->assertInstanceOf(VisibilityQuery::class, $sut);
$this->assertNull($sut->getCustomer());
$expected = new Customer();
$expected->setName('foo-bar');
$sut->setCustomer($expected);
$this->assertEquals($expected, $sut->getCustomer());
}
}

View File

@@ -0,0 +1,101 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\User;
use App\Tests\Repository\Query\BaseQueryTest;
use App\Entity\Activity;
use App\Entity\Customer;
use App\Entity\Project;
use App\Repository\Query\TimesheetQuery;
/**
* @covers \App\Repository\Query\TimesheetQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new TimesheetQuery();
$this->assertResultType($sut);
$this->assertHiddenEntity($sut);
$this->assertPage($sut);
$this->assertPageSize($sut);
$this->assertOrderBy($sut, 'begin');
$this->assertOrder($sut, TimesheetQuery::ORDER_DESC);
$this->assertUser($sut);
$this->assertCustomer($sut);
$this->assertProject($sut);
$this->assertActivity($sut);
$this->assertState($sut);
}
protected function assertUser(TimesheetQuery $sut)
{
$this->assertNull($sut->getUser());
$expected = new User();
$expected->setUsername('foo-bar');
$sut->setUser($expected);
$this->assertEquals($expected, $sut->getUser());
}
protected function assertCustomer(TimesheetQuery $sut)
{
$this->assertNull($sut->getCustomer());
$expected = new Customer();
$expected->setName('foo-bar');
$sut->setCustomer($expected);
$this->assertEquals($expected, $sut->getCustomer());
}
protected function assertProject(TimesheetQuery $sut)
{
$this->assertNull($sut->getProject());
$expected = new Project();
$expected->setName('foo-bar');
$sut->setProject($expected);
$this->assertEquals($expected, $sut->getProject());
}
protected function assertActivity(TimesheetQuery $sut)
{
$this->assertNull($sut->getActivity());
$expected = new Activity();
$expected->setName('foo-bar');
$sut->setActivity($expected);
$this->assertEquals($expected, $sut->getActivity());
}
protected function assertState(TimesheetQuery $sut)
{
$this->assertEquals(TimesheetQuery::STATE_ALL, $sut->getState());
$sut->setState('foo-bar');
$this->assertEquals(TimesheetQuery::STATE_ALL, $sut->getState());
$sut->setState(TimesheetQuery::STATE_STOPPED);
$this->assertEquals(TimesheetQuery::STATE_STOPPED, $sut->getState());
$sut->setState(TimesheetQuery::STATE_RUNNING);
$this->assertEquals(TimesheetQuery::STATE_RUNNING, $sut->getState());
$sut->setState(TimesheetQuery::STATE_ALL);
$this->assertEquals(TimesheetQuery::STATE_ALL, $sut->getState());
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\Repository\Query\UserQuery;
use App\Repository\Query\VisibilityQuery;
/**
* @covers \App\Repository\Query\UserQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class UserQueryTest extends BaseQueryTest
{
public function testQuery()
{
$sut = new UserQuery();
$this->assertBaseQuery($sut);
$this->assertInstanceOf(VisibilityQuery::class, $sut);
$this->assertRole($sut);
}
protected function assertRole(UserQuery $sut)
{
$this->assertNull($sut->getRole());
$sut->setRole('foo-bar');
$this->assertNull($sut->getRole());
$sut->setRole('ROLE_USER');
$this->assertEquals('ROLE_USER', $sut->getRole());
}
}

View File

@@ -0,0 +1,51 @@
<?php
/*
* This file is part of the Kimai package.
*
* (c) Kevin Papst <kevin@kevinpapst.de>
*
* 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\Repository\Query\VisibilityQuery;
use PHPUnit\Framework\TestCase;
/**
* @covers \App\Repository\Query\VisibilityQuery
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class VisibilityQueryTest extends TestCase
{
public function testVisibilityQuery()
{
$sut = new VisibilityQuery();
$this->assertFalse($sut->isExclusiveVisibility());
$this->assertEquals(VisibilityQuery::SHOW_VISIBLE, $sut->getVisibility());
$sut->setExclusiveVisibility(true);
$this->assertTrue($sut->isExclusiveVisibility());
$sut->setVisibility('foo-bar');
$this->assertEquals(VisibilityQuery::SHOW_VISIBLE, $sut->getVisibility());
$sut->setVisibility('2');
$this->assertEquals(VisibilityQuery::SHOW_HIDDEN, $sut->getVisibility());
$sut->setVisibility('0'); // keep the value that was previously set
$this->assertEquals(VisibilityQuery::SHOW_HIDDEN, $sut->getVisibility());
$sut->setVisibility(VisibilityQuery::SHOW_BOTH);
$this->assertEquals(VisibilityQuery::SHOW_BOTH, $sut->getVisibility());
$sut->setVisibility(VisibilityQuery::SHOW_HIDDEN);
$this->assertEquals(VisibilityQuery::SHOW_HIDDEN, $sut->getVisibility());
$sut->setVisibility(VisibilityQuery::SHOW_VISIBLE);
$this->assertEquals(VisibilityQuery::SHOW_VISIBLE, $sut->getVisibility());
}
}