Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
16bc04e
Defined strict types for IO contracts
alongosz Jul 8, 2025
9ed4b40
Defined template type for IO HandlerRegistry
alongosz Jul 8, 2025
e2fffbb
Fixed type hints for IOBinarydataHandler implementations
alongosz Jul 8, 2025
04d4062
Fixed type hints for IOMetadataHandler implementations
alongosz Jul 8, 2025
81e7128
Added missing type hints to IO UrlDecorator
alongosz Jul 8, 2025
0a2bfe2
Aligned NotFoundException `$previous` arg type with `\Exception` sign…
alongosz Jul 8, 2025
d06f1cf
Added missing type hints to IO\MimeTypeDetector\FileInfo
alongosz Jul 8, 2025
74d38cd
Fixed strict types in \Ibexa\Bundle\IO\Migration namespace
alongosz Jul 8, 2025
b41dd5d
Added missing type hints and improved code of Imagine VariationPurger
alongosz Jul 9, 2025
01ab1e3
Added missing type hints to IOServiceInterface and aligned related code
alongosz Jul 14, 2025
072d688
Added missing type hints to \Ibexa\Bundle\Core\Imagine\Filter\FilterC…
alongosz Jul 14, 2025
946ac5c
Added missing type hints to \Ibexa\Core\IO\FilePathNormalizer\Flysystem
alongosz Jul 14, 2025
578d353
Fixed strict types of MigrateFilesCommand and improved its code
alongosz Jul 15, 2025
77d86d6
[DI] Added missing type hints to IO Bundle Configuration
alongosz Jul 15, 2025
e1ce13a
Fixed strict types and improved IO Handler Configuration Factories
alongosz Jul 15, 2025
b3b5197
Added missing type hints to StreamFileListener
alongosz Jul 15, 2025
b482e84
Declared strict types and fixed IbexaIOBundle
alongosz Jul 15, 2025
30cb1ad
Declared strict types for MigrationFileListerPass
alongosz Jul 15, 2025
5d230f7
Declared strict types for FileMigratorInterface
alongosz Jul 15, 2025
78100f8
Declared strict types for BinaryStreamResponse
alongosz Jul 15, 2025
66bc4a4
Simplified LegacyStorageImageFileRowReader::getRow implementation
alongosz Jul 21, 2025
1077810
[Tests] Dropped obsolete test replaced by strict types
alongosz Jul 8, 2025
c2e18eb
[Tests] Aligned tests with the changes
alongosz Jul 8, 2025
689887a
[Tests] Aligned VariationPurger unit tests with the changes
alongosz Jul 9, 2025
242e14c
[Tests] Aligned IO\Migration tests with the changes
alongosz Jul 9, 2025
00a2d20
[Tests] Aligned IOServiceTest with the changes
alongosz Jul 9, 2025
c117694
[Tests] Fixed & refactored IORepositoryResolverTest
alongosz Jul 14, 2025
fb8c4c8
[Tests] Fixed & refactored LegacyTest after BinaryFile strict types c…
alongosz Jul 14, 2025
914063e
[Tests] Fixed strict types of IOConfigurationPassTest
alongosz Jul 15, 2025
fbb3bfc
[Tests] Improved quality of LegacyDFSClusterTest
alongosz Jul 15, 2025
be319fb
[Tests] Fixed ConfigurationFactory test cases
alongosz Jul 15, 2025
ce33ab0
[Tests] Improved \Ibexa\Tests\Bundle\IO\DependencyInjection\Configura…
alongosz Jul 15, 2025
c824970
[PHPStan] Removed resolved issues from the baseline
alongosz Jul 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Tests] Aligned VariationPurger unit tests with the changes
  • Loading branch information
alongosz committed Aug 6, 2025
commit 689887a1191a8afcc91d7b33e8af4131d14651ad
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Bundle\Core\Imagine\VariationPurger;

Expand All @@ -14,7 +15,10 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;

class IOVariationPurgerTest extends TestCase
/**
* @covers \Ibexa\Bundle\Core\Imagine\VariationPurger\IOVariationPurger
*/
final class IOVariationPurgerTest extends TestCase
{
public function testPurgesAliasList(): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,37 @@
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\Tests\Bundle\Core\Imagine\VariationPurger;

use ArrayIterator;
use Ibexa\Bundle\Core\Imagine\VariationPurger\ImageFileList;
use Ibexa\Bundle\Core\Imagine\VariationPurger\ImageFileVariationPurger;
use Ibexa\Contracts\Core\Variation\VariationPathGenerator;
use Ibexa\Core\IO\IOServiceInterface;
use Ibexa\Core\IO\Values\BinaryFile;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ImageFileVariationPurgerTest extends TestCase
/**
* @covers \Ibexa\Bundle\Core\Imagine\VariationPurger\ImageFileVariationPurger
*/
final class ImageFileVariationPurgerTest extends TestCase
{
/** @var \Ibexa\Core\IO\IOServiceInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $ioServiceMock;
protected IOServiceInterface & MockObject $ioServiceMock;

/** @var \Ibexa\Contracts\Core\Variation\VariationPathGenerator|\PHPUnit\Framework\MockObject\MockObject */
protected $pathGeneratorMock;
protected VariationPathGenerator & MockObject $pathGeneratorMock;

/** @var \Ibexa\Bundle\Core\Imagine\VariationPurger\ImageFileVariationPurger */
protected $purger;
protected ImageFileVariationPurger $purger;

protected function setUp(): void
{
$this->ioServiceMock = $this->createMock(IOServiceInterface::class);
$this->pathGeneratorMock = $this->createMock(VariationPathGenerator::class);
}

public function testIteratesOverItems()
public function testIteratesOverItems(): void
{
$purger = $this->createPurger(
[
Expand All @@ -53,7 +56,7 @@ public function testIteratesOverItems()
$purger->purge(['large', 'gallery']);
}

public function testPurgesExistingItem()
public function testPurgesExistingItem(): void
{
$purger = $this->createPurger(
['path/to/file.png']
Expand All @@ -62,17 +65,17 @@ public function testPurgesExistingItem()
$this->pathGeneratorMock
->expects(self::once())
->method('getVariationPath')
->will(self::returnValue('path/to/file_large.png'));
->willReturn('path/to/file_large.png');

$this->ioServiceMock
->expects(self::once())
->method('exists')
->will(self::returnValue(true));
->willReturn(true);

$this->ioServiceMock
->expects(self::once())
->method('loadBinaryFile')
->will(self::returnValue(new BinaryFile()));
->willReturn(new BinaryFile());

$this->ioServiceMock
->expects(self::once())
Expand All @@ -82,7 +85,7 @@ public function testPurgesExistingItem()
$purger->purge(['large']);
}

public function testDoesNotPurgeNotExistingItem()
public function testDoesNotPurgeNotExistingItem(): void
{
$purger = $this->createPurger(
['path/to/file.png']
Expand All @@ -91,12 +94,12 @@ public function testDoesNotPurgeNotExistingItem()
$this->pathGeneratorMock
->expects(self::once())
->method('getVariationPath')
->will(self::returnValue('path/to/file_large.png'));
->willReturn('path/to/file_large.png');

$this->ioServiceMock
->expects(self::once())
->method('exists')
->will(self::returnValue(false));
->willReturn(false);

$this->ioServiceMock
->expects(self::never())
Expand All @@ -109,8 +112,14 @@ public function testDoesNotPurgeNotExistingItem()
$purger->purge(['large']);
}

private function createPurger(array $fileList)
/**
* @param string[] $fileList
*/
private function createPurger(array $fileList): ImageFileVariationPurger
{
return new ImageFileVariationPurger(new ArrayIterator($fileList), $this->ioServiceMock, $this->pathGeneratorMock);
$imageFileList = new class($fileList) extends ArrayIterator implements ImageFileList {
};

return new ImageFileVariationPurger($imageFileList, $this->ioServiceMock, $this->pathGeneratorMock);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,39 @@
use Ibexa\Bundle\Core\Imagine\VariationPurger\LegacyStorageImageFileList;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Core\IO\IOConfigProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class LegacyStorageImageFileListTest extends TestCase
/**
* @covers \Ibexa\Bundle\Core\Imagine\VariationPurger\LegacyStorageImageFileList
*/
final class LegacyStorageImageFileListTest extends TestCase
{
/** @var \Ibexa\Bundle\Core\Imagine\VariationPurger\ImageFileRowReader|\PHPUnit\Framework\MockObject\MockObject */
protected $rowReaderMock;

/** @var \Ibexa\Bundle\Core\Imagine\VariationPurger\LegacyStorageImageFileList */
protected $fileList;

/** @var \Ibexa\Core\IO\IOConfigProvider|\PHPUnit\Framework\MockObject\MockObject */
private $ioConfigResolverMock;
protected ImageFileRowReader&MockObject $rowReaderMock;

/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface|\PHPUnit\Framework\MockObject\MockObject */
private $configResolverMock;
protected LegacyStorageImageFileList $fileList;

protected function setUp(): void
{
$this->rowReaderMock = $this->createMock(ImageFileRowReader::class);
$this->ioConfigResolverMock = $this->createMock(IOConfigProvider::class);
$this->ioConfigResolverMock
$ioConfigResolverMock = $this->createMock(IOConfigProvider::class);
$ioConfigResolverMock
->method('getLegacyUrlPrefix')
->willReturn('var/ibexa_demo_site/storage');
$this->configResolverMock = $this->createMock(ConfigResolverInterface::class);
$this->configResolverMock
$configResolverMock = $this->createMock(ConfigResolverInterface::class);
$configResolverMock
->method('getParameter')
->with('image.published_images_dir')
->willReturn('images');

$this->fileList = new LegacyStorageImageFileList(
$this->rowReaderMock,
$this->ioConfigResolverMock,
$this->configResolverMock
$ioConfigResolverMock,
$configResolverMock
);
}

public function testIterator()
public function testIterator(): void
{
$expected = [
'path/to/1st/image.jpg',
Expand All @@ -62,21 +58,36 @@ public function testIterator()
}

/**
* Tests that the iterator transforms the ezimagefile value into a binaryfile id.
* Tests that the iterator transforms the ibexa_image_file value into a binary file id.
*/
public function testImageIdTransformation()
public function testImageIdTransformation(): void
{
$this->configureRowReaderMock(['var/ibexa_demo_site/storage/images/path/to/1st/image.jpg']);
foreach ($this->fileList as $file) {
self::assertEquals('path/to/1st/image.jpg', $file);
}
}

private function configureRowReaderMock(array $fileList)
/**
* @param string[] $fileList
*/
private function configureRowReaderMock(array $fileList): void
{
$mockInvocator = $this->rowReaderMock->expects(self::any())->method('getRow');
call_user_func_array([$mockInvocator, 'willReturnOnConsecutiveCalls'], $fileList);
$fileListCount = count($fileList);
// iterator will try to invoke methods one more time to establish its end
$expectedIteratorInvocationsCount = $fileListCount + 1;

$index = 0;
$this->rowReaderMock
->expects(self::exactly($expectedIteratorInvocationsCount))
->method('getRow')
->willReturnCallback(static function () use (&$index, $fileList): ?string {
return $fileList[$index++] ?? null;
});

$this->rowReaderMock->expects(self::any())->method('getCount')->willReturn(count($fileList));
$this->rowReaderMock
->expects(self::exactly($expectedIteratorInvocationsCount))
->method('getCount')
->willReturn($fileListCount);
}
}