From 783b0f69f574a8cbc33c412393ead4e2e3c108ae Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Mon, 16 Dec 2024 16:37:12 +0100 Subject: [PATCH] Adjust for test API changes in blob Check things using FileApi instead of using the test API since that is now gone (or at least there are no longer any static methods and no global state) --- composer.json | 2 +- composer.lock | 12 ++++++------ tests/DocumentServiceTest.php | 15 ++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index a5aa262..d04a487 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": ">=8.1", "ext-json": "*", "api-platform/core": "^3.2", - "dbp/relay-blob-bundle": "^0.1.66", + "dbp/relay-blob-bundle": "^0.1.68", "dbp/relay-core-bundle": "^0.1.194", "doctrine/doctrine-bundle": "^2.13", "doctrine/doctrine-migrations-bundle": "^3.3", diff --git a/composer.lock b/composer.lock index 9413cbf..cf73369 100644 --- a/composer.lock +++ b/composer.lock @@ -289,16 +289,16 @@ }, { "name": "dbp/relay-blob-bundle", - "version": "v0.1.67", + "version": "v0.1.69", "source": { "type": "git", "url": "https://github.com/digital-blueprint/relay-blob-bundle.git", - "reference": "db8e796d1c1065dd1845a1c35eea72bd67a24d31" + "reference": "1b66d2349e353b0b491dcbd071effd88d08779b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/digital-blueprint/relay-blob-bundle/zipball/db8e796d1c1065dd1845a1c35eea72bd67a24d31", - "reference": "db8e796d1c1065dd1845a1c35eea72bd67a24d31", + "url": "https://api.github.com/repos/digital-blueprint/relay-blob-bundle/zipball/1b66d2349e353b0b491dcbd071effd88d08779b0", + "reference": "1b66d2349e353b0b491dcbd071effd88d08779b0", "shasum": "" }, "require": { @@ -361,9 +361,9 @@ "description": "A bundle for file-serving, persisting and managing", "support": { "issues": "https://github.com/digital-blueprint/relay-blob-bundle/issues", - "source": "https://github.com/digital-blueprint/relay-blob-bundle/tree/v0.1.67" + "source": "https://github.com/digital-blueprint/relay-blob-bundle/tree/v0.1.69" }, - "time": "2024-12-11T10:47:35+00:00" + "time": "2024-12-16T15:21:10+00:00" }, { "name": "dbp/relay-blob-library", diff --git a/tests/DocumentServiceTest.php b/tests/DocumentServiceTest.php index 3ded68d..5e49319 100644 --- a/tests/DocumentServiceTest.php +++ b/tests/DocumentServiceTest.php @@ -5,8 +5,8 @@ namespace Dbp\Relay\BlobConnectorCampusonlineDmsBundle\Tests; use ApiPlatform\Symfony\Bundle\Test\ApiTestCase; +use Dbp\Relay\BlobBundle\Api\FileApi; use Dbp\Relay\BlobBundle\TestUtils\BlobTestUtils; -use Dbp\Relay\BlobBundle\TestUtils\TestDatasystemProviderService; use Dbp\Relay\BlobBundle\TestUtils\TestEntityManager; use Dbp\Relay\BlobConnectorCampusonlineDmsBundle\Entity\Document; use Dbp\Relay\BlobConnectorCampusonlineDmsBundle\Service\DocumentService; @@ -18,6 +18,7 @@ class DocumentServiceTest extends ApiTestCase private const TEST_FILE_2_NAME = 'test_patch.txt'; protected ?DocumentService $documentService = null; protected ?TestEntityManager $blobTestEntityManager = null; + private FileApi $fileApi; protected function setUp(): void { @@ -33,10 +34,11 @@ protected function setUpFileApi(): void ]; $this->blobTestEntityManager = new TestEntityManager(self::bootKernel()->getContainer()); - $this->documentService = new DocumentService(BlobTestUtils::createTestFileApi( + $this->fileApi = BlobTestUtils::createTestFileApi( $this->blobTestEntityManager->getEntityManager(), $testConfig - )); + ); + $this->documentService = new DocumentService($this->fileApi); } /** @@ -66,10 +68,9 @@ public function testCreateDocument(): void $this->assertEquals($file->getSize(), $document->getLatestVersion()->getSize()); $this->assertEquals($file->getMimeType(), $document->getLatestVersion()->getMediaType()); - $this->assertTrue(TestDatasystemProviderService::hasFile( - self::getInternalBucketId(), $document->getLatestVersion()->getUid())); - $this->assertTrue(TestDatasystemProviderService::isContentEqual( - self::getInternalBucketId(), $document->getLatestVersion()->getUid(), $file)); + $res = $this->fileApi->getFile($document->getLatestVersion()->getUid()); + $this->assertNotNull($res->getFile()); + $this->assertSame($file->getContent(), $res->getFile()->getContent()); } protected static function getInternalBucketId(): ?string