mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
Improve admin UX for configuration of document template (document generation)
This commit is contained in:
@@ -9,7 +9,7 @@ declare(strict_types=1);
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Tests;
|
||||
namespace Chill\DocStoreBundle\Tests\Service;
|
||||
|
||||
use ChampsLibres\AsyncUploaderBundle\TempUrl\TempUrlGeneratorInterface;
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
@@ -117,6 +117,41 @@ final class StoredObjectManagerTest extends TestCase
|
||||
self::assertEquals($clearContent, $storedObjectManager->read($storedObject));
|
||||
}
|
||||
|
||||
public function testWriteWithDeleteAt()
|
||||
{
|
||||
$storedObject = new StoredObject();
|
||||
|
||||
$expectedRequests = [
|
||||
function ($method, $url, $options): MockResponse {
|
||||
self::assertEquals('PUT', $method);
|
||||
self::assertArrayHasKey('headers', $options);
|
||||
self::assertIsArray($options['headers']);
|
||||
self::assertCount(0, array_filter($options['headers'], fn (string $header) => str_contains($header, 'X-Delete-At')));
|
||||
|
||||
return new MockResponse('', ['http_code' => 201]);
|
||||
},
|
||||
|
||||
function ($method, $url, $options): MockResponse {
|
||||
self::assertEquals('PUT', $method);
|
||||
self::assertArrayHasKey('headers', $options);
|
||||
self::assertIsArray($options['headers']);
|
||||
self::assertCount(1, array_filter($options['headers'], fn (string $header) => str_contains($header, 'X-Delete-At')));
|
||||
self::assertContains('X-Delete-At: 1711014260', $options['headers']);
|
||||
|
||||
return new MockResponse('', ['http_code' => 201]);
|
||||
},
|
||||
];
|
||||
$client = new MockHttpClient($expectedRequests);
|
||||
|
||||
$manager = new StoredObjectManager($client, $this->getTempUrlGenerator($storedObject));
|
||||
|
||||
$manager->write($storedObject, 'ok');
|
||||
|
||||
// with a deletedAt date
|
||||
$storedObject->setDeleteAt(\DateTimeImmutable::createFromFormat('U', '1711014260'));
|
||||
$manager->write($storedObject, 'ok');
|
||||
}
|
||||
|
||||
private function getHttpClient(string $encodedContent): HttpClientInterface
|
||||
{
|
||||
$callback = static function ($method, $url, $options) use ($encodedContent) {
|
Reference in New Issue
Block a user