Apply new CS rules on the webdav feature

This commit is contained in:
2024-01-15 20:38:03 +01:00
parent fca929f56f
commit 4cff706306
14 changed files with 104 additions and 108 deletions

View File

@@ -14,18 +14,16 @@ namespace Chill\DocStoreBundle\Tests\Controller;
use Chill\DocStoreBundle\Controller\WebdavController;
use Chill\DocStoreBundle\Entity\StoredObject;
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
use DateTimeInterface;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Ramsey\Uuid\Uuid;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Templating\EngineInterface;
/**
* @internal
*
* @coversNothing
*/
class WebdavControllerTest extends KernelTestCase
@@ -124,7 +122,7 @@ class WebdavControllerTest extends KernelTestCase
self::assertEquals($expectedStatusCode, $response->getStatusCode());
self::assertContains('content-type', $response->headers->keys());
self::assertStringContainsString('text/xml', $response->headers->get('content-type'));
self::assertTrue((new \DOMDocument())->loadXML($response->getContent()), $message . " test that the xml response is a valid xml");
self::assertTrue((new \DOMDocument())->loadXML($response->getContent()), $message.' test that the xml response is a valid xml');
self::assertXmlStringEqualsXmlString($expectedXmlResponse, $response->getContent(), $message);
}
@@ -137,13 +135,13 @@ class WebdavControllerTest extends KernelTestCase
$request = new Request([], [], [], [], [], [], $requestContent);
$request->setMethod('PROPFIND');
$request->headers->add(["Depth" => "0"]);
$request->headers->add(['Depth' => '0']);
$response = $controller->propfindDirectory($this->buildDocument(), '1234', $request);
self::assertEquals($expectedStatusCode, $response->getStatusCode());
self::assertContains('content-type', $response->headers->keys());
self::assertStringContainsString('text/xml', $response->headers->get('content-type'));
self::assertTrue((new \DOMDocument())->loadXML($response->getContent()), $message . " test that the xml response is a valid xml");
self::assertTrue((new \DOMDocument())->loadXML($response->getContent()), $message.' test that the xml response is a valid xml');
self::assertXmlStringEqualsXmlString($expectedXmlResponse, $response->getContent(), $message);
}
@@ -192,7 +190,7 @@ class WebdavControllerTest extends KernelTestCase
</d:multistatus>
XML;
yield [$content, 207, $response, "get IsReadOnly and contenttype from server"];
yield [$content, 207, $response, 'get IsReadOnly and contenttype from server'];
$content =
<<<'XML'
@@ -220,7 +218,7 @@ class WebdavControllerTest extends KernelTestCase
</d:multistatus>
XML;
yield [$content, 207, $response, "get property IsReadOnly"];
yield [$content, 207, $response, 'get property IsReadOnly'];
yield [
<<<'XML'
@@ -246,7 +244,7 @@ class WebdavControllerTest extends KernelTestCase
</d:response>
</d:multistatus>
XML,
"Test requesting an unknow property"
'Test requesting an unknow property',
];
yield [
@@ -274,7 +272,7 @@ class WebdavControllerTest extends KernelTestCase
</d:response>
</d:multistatus>
XML,
"test getting the last modified date"
'test getting the last modified date',
];
yield [
@@ -311,7 +309,7 @@ class WebdavControllerTest extends KernelTestCase
</d:response>
</d:multistatus>
XML,
"test finding all properties"
'test finding all properties',
];
}
@@ -356,7 +354,7 @@ class WebdavControllerTest extends KernelTestCase
</d:response>
</d:multistatus>
XML,
"test resourceType and IsReadOnly "
'test resourceType and IsReadOnly ',
];
yield [
@@ -379,15 +377,14 @@ class WebdavControllerTest extends KernelTestCase
</d:response>
</d:multistatus>
XML,
"test creatableContentsInfo"
'test creatableContentsInfo',
];
}
}
class MockedStoredObjectManager implements StoredObjectManagerInterface
{
public function getLastModified(StoredObject $document): DateTimeInterface
public function getLastModified(StoredObject $document): \DateTimeInterface
{
return new \DateTimeImmutable('2023-09-13T14:15');
}
@@ -402,11 +399,12 @@ class MockedStoredObjectManager implements StoredObjectManagerInterface
return 'abcde';
}
public function write(StoredObject $document, string $clearContent): void {}
public function write(StoredObject $document, string $clearContent): void
{
}
public function etag(StoredObject $document): string
{
return 'ab56b4d92b40713acc5af89985d4b786';
}
}