Skip to content

Commit

Permalink
Adjust for test API changes in blob
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
lazka committed Dec 16, 2024
1 parent 273b9b5 commit 783b0f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions tests/DocumentServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand All @@ -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);
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 783b0f6

Please sign in to comment.