added invoice archive & configurable invoice numbers (#1541)
This commit is contained in:
43
tests/Repository/Loader/AbstractLoaderTest.php
Normal file
43
tests/Repository/Loader/AbstractLoaderTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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\Loader;
|
||||
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractLoaderTest extends TestCase
|
||||
{
|
||||
protected function getEntityManagerMock(int $createQueryBuilderCount)
|
||||
{
|
||||
$em = $this->createMock(EntityManager::class);
|
||||
$qb = $this->createMock(QueryBuilder::class);
|
||||
$query = $this->createMock(AbstractQuery::class);
|
||||
$expr = $this->createMock(Expr::class);
|
||||
|
||||
$expr->expects($this->any())->method('isNotNull')->willReturn('');
|
||||
$expr->expects($this->any())->method('in')->willReturn('');
|
||||
|
||||
$qb->expects($this->any())->method('andWhere')->willReturnSelf();
|
||||
$qb->expects($this->any())->method('from')->willReturnSelf();
|
||||
$qb->expects($this->any())->method('expr')->willReturn($expr);
|
||||
$qb->expects($this->any())->method('from')->willReturnSelf();
|
||||
$qb->expects($this->any())->method('select')->willReturnSelf();
|
||||
$qb->expects($this->any())->method('leftJoin')->willReturnSelf();
|
||||
$qb->expects($this->any())->method('getQuery')->willReturn($query);
|
||||
$query->expects($this->any())->method('execute')->willReturn(null);
|
||||
|
||||
$em->expects($this->exactly($createQueryBuilderCount))->method('createQueryBuilder')->willReturn($qb);
|
||||
|
||||
return $em;
|
||||
}
|
||||
}
|
||||
33
tests/Repository/Loader/ActivityLoaderTest.php
Normal file
33
tests/Repository/Loader/ActivityLoaderTest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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\Loader;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Repository\Loader\ActivityLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Loader\ActivityLoader
|
||||
* @covers \App\Repository\Loader\ActivityIdLoader
|
||||
*/
|
||||
class ActivityLoaderTest extends AbstractLoaderTest
|
||||
{
|
||||
public function testLoadResults()
|
||||
{
|
||||
// mock needs improvements, because it should be 5
|
||||
$em = $this->getEntityManagerMock(2);
|
||||
|
||||
$sut = new ActivityLoader($em);
|
||||
|
||||
$entity = $this->createMock(Activity::class);
|
||||
$entity->expects($this->once())->method('getId')->willReturn(1);
|
||||
|
||||
$sut->loadResults([$entity]);
|
||||
}
|
||||
}
|
||||
32
tests/Repository/Loader/CustomerLoaderTest.php
Normal file
32
tests/Repository/Loader/CustomerLoaderTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Loader;
|
||||
|
||||
use App\Entity\Customer;
|
||||
use App\Repository\Loader\CustomerLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Loader\CustomerLoader
|
||||
* @covers \App\Repository\Loader\CustomerIdLoader
|
||||
*/
|
||||
class CustomerLoaderTest extends AbstractLoaderTest
|
||||
{
|
||||
public function testLoadResults()
|
||||
{
|
||||
$em = $this->getEntityManagerMock(2);
|
||||
|
||||
$sut = new CustomerLoader($em);
|
||||
|
||||
$entity = $this->createMock(Customer::class);
|
||||
$entity->expects($this->once())->method('getId')->willReturn(1);
|
||||
|
||||
$sut->loadResults([$entity]);
|
||||
}
|
||||
}
|
||||
32
tests/Repository/Loader/InvoiceLoaderTest.php
Normal file
32
tests/Repository/Loader/InvoiceLoaderTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Loader;
|
||||
|
||||
use App\Entity\Invoice;
|
||||
use App\Repository\Loader\InvoiceLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Loader\InvoiceLoader
|
||||
* @covers \App\Repository\Loader\InvoiceIdLoader
|
||||
*/
|
||||
class InvoiceLoaderTest extends AbstractLoaderTest
|
||||
{
|
||||
public function testLoadResults()
|
||||
{
|
||||
$em = $this->getEntityManagerMock(2);
|
||||
|
||||
$sut = new InvoiceLoader($em);
|
||||
|
||||
$entity = $this->createMock(Invoice::class);
|
||||
$entity->expects($this->once())->method('getId')->willReturn(1);
|
||||
|
||||
$sut->loadResults([$entity]);
|
||||
}
|
||||
}
|
||||
32
tests/Repository/Loader/ProjectLoaderTest.php
Normal file
32
tests/Repository/Loader/ProjectLoaderTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Loader;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Repository\Loader\ProjectLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Loader\ProjectLoader
|
||||
* @covers \App\Repository\Loader\ProjectIdLoader
|
||||
*/
|
||||
class ProjectLoaderTest extends AbstractLoaderTest
|
||||
{
|
||||
public function testLoadResults()
|
||||
{
|
||||
$em = $this->getEntityManagerMock(4);
|
||||
|
||||
$sut = new ProjectLoader($em);
|
||||
|
||||
$entity = $this->createMock(Project::class);
|
||||
$entity->expects($this->once())->method('getId')->willReturn(1);
|
||||
|
||||
$sut->loadResults([$entity]);
|
||||
}
|
||||
}
|
||||
32
tests/Repository/Loader/TeamLoaderTest.php
Normal file
32
tests/Repository/Loader/TeamLoaderTest.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\Loader;
|
||||
|
||||
use App\Entity\Team;
|
||||
use App\Repository\Loader\TeamLoader;
|
||||
|
||||
/**
|
||||
* @covers \App\Repository\Loader\TeamLoader
|
||||
* @covers \App\Repository\Loader\TeamIdLoader
|
||||
*/
|
||||
class TeamLoaderTest extends AbstractLoaderTest
|
||||
{
|
||||
public function testLoadResults()
|
||||
{
|
||||
$em = $this->getEntityManagerMock(1);
|
||||
|
||||
$sut = new TeamLoader($em);
|
||||
|
||||
$entity = $this->createMock(Team::class);
|
||||
$entity->expects($this->once())->method('getId')->willReturn(1);
|
||||
|
||||
$sut->loadResults([$entity]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user