-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
4 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* @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\AdminUi\UI\Config\Provider\Module; | ||
|
||
use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface; | ||
|
||
/** | ||
* @template TConfig of array{ | ||
* imageFieldDefinitionIdentifiers: array<string>, | ||
* imageContentTypeIdentifiers: array<string>, | ||
* aggregations: array<string, array<string, string>>, | ||
* } | ||
*/ | ||
final class ImagePicker implements ProviderInterface | ||
{ | ||
/** @phpstan-var TConfig */ | ||
private array $config; | ||
|
||
/** | ||
* @phpstan-param TConfig $config | ||
*/ | ||
public function __construct(array $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* @phpstan-return TConfig | ||
*/ | ||
public function getConfig(): array | ||
{ | ||
return $this->config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/** | ||
* @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\AdminUi\UI\Config\Provider\Module; | ||
|
||
use Ibexa\AdminUi\UI\Config\Provider\Module\ImagePicker; | ||
use Ibexa\Contracts\AdminUi\UI\Config\ProviderInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class ImagePickerTest extends TestCase | ||
{ | ||
private const FIELD_DEFINITION_IDENTIFIERS = ['field_foo', 'field_bar']; | ||
private const CONTENT_TYPE_IDENTIFIERS = ['content_type_foo', 'content_type_bar']; | ||
private const AGGREGATIONS = [ | ||
'KeywordTermAggregation' => [ | ||
'name' => 'keywords', | ||
'contentTypeIdentifier' => 'keywords', | ||
'fieldDefinitionIdentifier' => 'keywords', | ||
], | ||
]; | ||
|
||
private ProviderInterface $provider; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->provider = new ImagePicker( | ||
[ | ||
'imageFieldDefinitionIdentifiers' => self::FIELD_DEFINITION_IDENTIFIERS, | ||
'imageContentTypeIdentifiers' => self::CONTENT_TYPE_IDENTIFIERS, | ||
'aggregations' => self::AGGREGATIONS, | ||
] | ||
); | ||
} | ||
|
||
public function testGetConfig(): void | ||
{ | ||
self::assertSame( | ||
[ | ||
'imageFieldDefinitionIdentifiers' => self::FIELD_DEFINITION_IDENTIFIERS, | ||
'imageContentTypeIdentifiers' => self::CONTENT_TYPE_IDENTIFIERS, | ||
'aggregations' => self::AGGREGATIONS, | ||
], | ||
$this->provider->getConfig() | ||
); | ||
} | ||
} |