Skip to content

Commit

Permalink
Fix ViewConfigTest
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Sep 27, 2023
1 parent 989abc1 commit 6d51453
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Core/ViewConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

namespace OxidEsales\MediaLibrary\Core;

use OxidEsales\MediaLibrary\Image\Service\ImageResourceInterface;

/**
* Class ViewConfig
*
Expand All @@ -23,7 +25,7 @@ class ViewConfig extends ViewConfig_parent
{
public function getMediaUrl($sFile = '')
{
$imageResource = $this->getService('OxidEsales\MediaLibrary\Image\Service\ImageResourceInterface');
$imageResource = $this->getService(ImageResourceInterface::class);
return $imageResource->getMediaUrl($sFile);
}
}
13 changes: 9 additions & 4 deletions tests/Integration/Core/ViewConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@

namespace OxidEsales\MediaLibrary\Tests\Integration\Core;

use OxidEsales\MediaLibrary\Image\Service\ImageResource;
use OxidEsales\MediaLibrary\Core\ViewConfig;
use OxidEsales\MediaLibrary\Image\Service\ImageResourceInterface;
use OxidEsales\MediaLibrary\Tests\Integration\IntegrationTestCase;

/**
* Class ddVisualEditorOxViewConfigTest
* @covers \OxidEsales\MediaLibrary\Core\ViewConfig
*/
class ViewConfigTest extends IntegrationTestCase
{
public function testGetMediaUrl(): void
{
$imageResourceMock = $this->createPartialMock(imageResource::class, ['getMediaUrl']);
$imageResourceMock = $this->createMock(ImageResourceInterface::class);
$imageResourceMock->method('getMediaUrl')->with('someFile')->willReturn('someFilePath');

$this->assertSame('someFilePath', $imageResourceMock->getMediaUrl('someFile'));
$sut = $this->createPartialMock(ViewConfig::class, ['getService']);
$sut->method('getService')->willReturnMap([
[ImageResourceInterface::class, $imageResourceMock]
]);

$this->assertSame('someFilePath', $sut->getMediaUrl('someFile'));
}
}

0 comments on commit 6d51453

Please sign in to comment.