mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
fix some tests
This commit is contained in:
@@ -19,6 +19,7 @@ use Chill\DocGeneratorBundle\Service\Generator\Generator;
|
||||
use Chill\DocGeneratorBundle\Service\Generator\ObjectReadyException;
|
||||
use Chill\DocGeneratorBundle\Service\Generator\RelatedEntityNotFoundException;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Entity\StoredObjectVersion;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -39,11 +40,11 @@ class GeneratorTest extends TestCase
|
||||
|
||||
public function testSuccessfulGeneration(): void
|
||||
{
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject = (new StoredObject())
|
||||
->setType('application/test'));
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_PENDING);
|
||||
$reflection = new \ReflectionClass($destinationStoredObject);
|
||||
$reflection->getProperty('id')->setAccessible(true);
|
||||
$reflection->getProperty('id')->setValue($destinationStoredObject, 1);
|
||||
$entity = new class () {};
|
||||
$data = [];
|
||||
@@ -76,7 +77,14 @@ class GeneratorTest extends TestCase
|
||||
|
||||
$storedObjectManager = $this->prophesize(StoredObjectManagerInterface::class);
|
||||
$storedObjectManager->read($templateStoredObject)->willReturn('template');
|
||||
$storedObjectManager->write($destinationStoredObject, 'generated')->shouldBeCalled();
|
||||
$storedObjectManager->write($destinationStoredObject, 'generated', 'application/test')
|
||||
->will(function ($args): StoredObjectVersion {
|
||||
/** @var StoredObject $storedObject */
|
||||
$storedObject = $args[0];
|
||||
|
||||
return $storedObject->registerVersion(type: $args[2]);
|
||||
})
|
||||
->shouldBeCalled();
|
||||
|
||||
$generator = new Generator(
|
||||
$contextManagerInterface->reveal(),
|
||||
@@ -107,8 +115,9 @@ class GeneratorTest extends TestCase
|
||||
$this->prophesize(StoredObjectManagerInterface::class)->reveal()
|
||||
);
|
||||
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject = (new StoredObject())
|
||||
->setType('application/test'));
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_READY);
|
||||
|
||||
$generator->generateDocFromTemplate(
|
||||
@@ -124,11 +133,11 @@ class GeneratorTest extends TestCase
|
||||
{
|
||||
$this->expectException(RelatedEntityNotFoundException::class);
|
||||
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject = (new StoredObject())
|
||||
->setType('application/test'));
|
||||
$templateStoredObject = new StoredObject();
|
||||
$templateStoredObject->registerVersion(type: 'application/test');
|
||||
$template = (new DocGeneratorTemplate())->setFile($templateStoredObject);
|
||||
$destinationStoredObject = (new StoredObject())->setStatus(StoredObject::STATUS_PENDING);
|
||||
$reflection = new \ReflectionClass($destinationStoredObject);
|
||||
$reflection->getProperty('id')->setAccessible(true);
|
||||
$reflection->getProperty('id')->setValue($destinationStoredObject, 1);
|
||||
|
||||
$context = $this->prophesize(DocGeneratorContextInterface::class);
|
||||
|
Reference in New Issue
Block a user