Commit c5287d35 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Tests unitaires.

parent 48ce8c20
......@@ -22,13 +22,15 @@
"zfcampus/zf-apigility-doctrine": "^2.1",
"doctrine/doctrine-orm-module": "^1.1",
"zendframework/zend-console": "^2.7",
"unicaen/oracle": "^1.2"
"unicaen/oracle": "^1.2",
"doctrine/common": "^2.7"
},
"require-dev": {
"zendframework/zend-developer-tools": "^1.1",
"zfcampus/zf-apigility-admin": "^1.5.9",
"zfcampus/zf-deploy": "^1.2",
"squizlabs/php_codesniffer": "^3.3"
"squizlabs/php_codesniffer": "^3.3",
"phpunit/phpunit": "^6.5"
},
"autoload": {
"psr-4": {
......@@ -41,7 +43,8 @@
},
"autoload-dev": {
"psr-4": {
"ApplicationTest\\": "module/Application/test/"
"ApplicationTest\\": "module/Application/test/",
"ImportDataTest\\": "module/ImportData/test/"
}
},
"scripts": {
......
This diff is collapsed.
......@@ -5,6 +5,11 @@ use ZF\Apigility\Provider\ApigilityProviderInterface;
class Module implements ApigilityProviderInterface
{
/**
* @return array
*
* @codeCoverageIgnore
*/
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Acteur
*
* @codeCoverageIgnore
*/
class Acteur
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Doctorant
*
* @codeCoverageIgnore
*/
class Doctorant
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Structure
*
* @codeCoverageIgnore
*/
class EcoleDoctorale
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Structure
*
* @codeCoverageIgnore
*/
class Etablissement
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Financement
*
* @codeCoverageIgnore
*/
class Financement
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* These
*
* @codeCoverageIgnore
*/
class Individu
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* OrigineFinancement
*
* @codeCoverageIgnore
*/
class OrigineFinancement
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Role
*
* @codeCoverageIgnore
*/
class Role
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Source
*
* @codeCoverageIgnore
*/
class Source
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Structure
*
* @codeCoverageIgnore
*/
class Structure
{
......
......@@ -4,10 +4,11 @@ namespace ImportData\V1\Entity\Db;
/**
* These
*
* @codeCoverageIgnore
*/
class These
{
protected $id;
protected $sourceId;
protected $etatThese;
......@@ -63,8 +64,6 @@ class These
$this->uniteRechId = $uniteRechId;
}
/**
* @return mixed
*/
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* TitreAcces
*
* @codeCoverageIgnore
*/
class TitreAcces
{
......
......@@ -4,6 +4,8 @@ namespace ImportData\V1\Entity\Db;
/**
* Structure
*
* @codeCoverageIgnore
*/
class UniteRecherche
{
......
......@@ -4,10 +4,11 @@ namespace ImportData\V1\Entity\Db;
/**
* Variable
*
* @codeCoverageIgnore
*/
class Variable
{
/**
* @var integer
*/
......
......@@ -7,29 +7,31 @@ use ZF\Rest\AbstractResourceListener;
class VersionResource extends AbstractResourceListener
{
const VERSION_INCONNUE = 'Inconnue';
/**
* @var VersionEntity
* @var string
*/
private $versionEntity;
private $version;
/**
* VersionResource constructor.
*
* @param VersionEntity $versionEntity
* @param string $version
*/
public function __construct(VersionEntity $versionEntity)
public function __construct($version = null)
{
$this->versionEntity = $versionEntity;
$this->version = $version ?: self::VERSION_INCONNUE;
}
/**
* Fetch a resource
*
* @param mixed $id
* @return ApiProblem|mixed
* @param string $id
* @return VersionEntity
*/
public function fetch($id)
{
return $this->versionEntity;
return new VersionEntity($this->version);
}
}
......@@ -13,15 +13,8 @@ class VersionResourceFactory
public function __invoke(ContainerInterface $container)
{
$config = $container->get('config');
$version = isset($config['version']) ? $config['version'] : null;
if (isset($config['version'])) {
$version = $config['version'];
} else {
$version = "Inconnue";
}
$entity = new VersionEntity($version);
return new VersionResource($entity);
return new VersionResource($version);
}
}
<?php
namespace ImportDataTest\V1\Query\Provider;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use ImportData\V1\Query\Provider\FetchAll;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use ZF\Rest\ResourceEvent;
class FetchAllTest extends TestCase
{
public function testCreateQueryAddsOrderBy()
{
/** @var ResourceEvent|MockObject $resourceEvent */
$resourceEvent = $this->createMock(ResourceEvent::class);
/** @var MockObject $expectedQb */
$expectedQb = $this->createMock(QueryBuilder::class);
$expectedQb->expects($this->once())->method('select')->willReturnSelf();
/** @var EntityManager|MockObject $objectManager */
$objectManager = $this->createMock(EntityManager::class);
$objectManager->expects($this->once())->method('createQueryBuilder')->willReturn($expectedQb);
$provider = new FetchAll();
$provider->setObjectManager($objectManager);
$expectedQb->expects($this->once())->method('orderBy')->with('row.id', 'asc');
$qb = $provider->createQuery($resourceEvent, 'EntityClass', []);
$this->assertSame($expectedQb, $qb);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment