mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fix test
This commit is contained in:
parent
5fefe09a39
commit
ce5659219a
@ -14,6 +14,7 @@ namespace Chill\DocStoreBundle\Tests\Controller;
|
|||||||
use Chill\DocStoreBundle\Controller\WebdavController;
|
use Chill\DocStoreBundle\Controller\WebdavController;
|
||||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Prophecy\Argument;
|
use Prophecy\Argument;
|
||||||
use Prophecy\PhpUnit\ProphecyTrait;
|
use Prophecy\PhpUnit\ProphecyTrait;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
@ -39,20 +40,25 @@ class WebdavControllerTest extends KernelTestCase
|
|||||||
$this->engine = self::getContainer()->get(\Twig\Environment::class);
|
$this->engine = self::getContainer()->get(\Twig\Environment::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildController(): WebdavController
|
private function buildController(EntityManagerInterface $entityManager = null): WebdavController
|
||||||
{
|
{
|
||||||
$storedObjectManager = new MockedStoredObjectManager();
|
$storedObjectManager = new MockedStoredObjectManager();
|
||||||
$security = $this->prophesize(Security::class);
|
$security = $this->prophesize(Security::class);
|
||||||
$security->isGranted(Argument::in(['EDIT', 'SEE']), Argument::type(StoredObject::class))
|
$security->isGranted(Argument::in(['EDIT', 'SEE']), Argument::type(StoredObject::class))
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
return new WebdavController($this->engine, $storedObjectManager, $security->reveal());
|
if (null === $entityManager) {
|
||||||
|
$entityManager = $this->createMock(EntityManagerInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new WebdavController($this->engine, $storedObjectManager, $security->reveal(), $entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildDocument(): StoredObject
|
private function buildDocument(): StoredObject
|
||||||
{
|
{
|
||||||
$object = (new StoredObject())
|
$object = (new StoredObject())
|
||||||
->setType('application/vnd.oasis.opendocument.text');
|
->registerVersion(type: 'application/vnd.oasis.opendocument.text')
|
||||||
|
->getStoredObject();
|
||||||
|
|
||||||
$reflectionObject = new \ReflectionClass($object);
|
$reflectionObject = new \ReflectionClass($object);
|
||||||
$reflectionObjectUuid = $reflectionObject->getProperty('uuid');
|
$reflectionObjectUuid = $reflectionObject->getProperty('uuid');
|
||||||
@ -384,24 +390,27 @@ class WebdavControllerTest extends KernelTestCase
|
|||||||
|
|
||||||
class MockedStoredObjectManager implements StoredObjectManagerInterface
|
class MockedStoredObjectManager implements StoredObjectManagerInterface
|
||||||
{
|
{
|
||||||
public function getLastModified(StoredObject $document): \DateTimeInterface
|
public function getLastModified(StoredObject|\Chill\DocStoreBundle\Entity\StoredObjectVersion $document): \DateTimeInterface
|
||||||
{
|
{
|
||||||
return new \DateTimeImmutable('2023-09-13T14:15');
|
return new \DateTimeImmutable('2023-09-13T14:15', new \DateTimeZone('+02:00'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContentLength(StoredObject $document): int
|
public function getContentLength(StoredObject|\Chill\DocStoreBundle\Entity\StoredObjectVersion $document): int
|
||||||
{
|
{
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function read(StoredObject $document): string
|
public function read(StoredObject|\Chill\DocStoreBundle\Entity\StoredObjectVersion $document): string
|
||||||
{
|
{
|
||||||
return 'abcde';
|
return 'abcde';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function write(StoredObject $document, string $clearContent): void {}
|
public function write(StoredObject $document, string $clearContent, ?string $contentType = null): \Chill\DocStoreBundle\Entity\StoredObjectVersion
|
||||||
|
{
|
||||||
|
return $document->registerVersion();
|
||||||
|
}
|
||||||
|
|
||||||
public function etag(StoredObject $document): string
|
public function etag(StoredObject|\Chill\DocStoreBundle\Entity\StoredObjectVersion $document): string
|
||||||
{
|
{
|
||||||
return 'ab56b4d92b40713acc5af89985d4b786';
|
return 'ab56b4d92b40713acc5af89985d4b786';
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user