|
|
@@ -1,6 +1,36 @@
|
|
|
<?php
|
|
|
|
|
|
-class ApiLegacyStorageTest extends \PHPUnit\Framework\TestCase
|
|
|
+use App\Entity\Core\File;
|
|
|
+use App\Service\ApiLegacy\ApiLegacyRequestService;
|
|
|
+use App\Service\Storage\ApiLegacyStorage;
|
|
|
+use PHPUnit\Framework\TestCase;
|
|
|
+
|
|
|
+class ApiLegacyStorageTest extends TestCase
|
|
|
{
|
|
|
+ public function testRead(): void
|
|
|
+ {
|
|
|
+ $apiLegacyRequestService = $this->getMockBuilder(ApiLegacyRequestService::class)
|
|
|
+ ->disableOriginalConstructor()
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $apiLegacyStorageTest = $this
|
|
|
+ ->getMockBuilder(ApiLegacyStorage::class)
|
|
|
+ ->setConstructorArgs([$apiLegacyRequestService])
|
|
|
+ ->setMethodsExcept(['read'])
|
|
|
+ ->getMock();
|
|
|
+
|
|
|
+ $file = $this->getMockBuilder(File::class)->getMock();
|
|
|
+ $file->method('getId')->willReturn(123);
|
|
|
+
|
|
|
+ $apiLegacyRequestService
|
|
|
+ ->expects(self::once())
|
|
|
+ ->method('getContent')
|
|
|
+ ->with('api/files/123/download')
|
|
|
+ ->willReturn('xyz');
|
|
|
+
|
|
|
+ $result = $apiLegacyStorageTest->read($file);
|
|
|
+
|
|
|
+ $this->assertEquals('xyz', $result);
|
|
|
+ }
|
|
|
|
|
|
}
|