Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kisztof committed Jun 30, 2023
1 parent 1455361 commit 0938085
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ interface NameSchemaServiceInterface
{
public function resolveUrlAliasSchema(Content $content, ContentType $contentType = null): array;

public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null);
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null): array;

public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array;
}
4 changes: 2 additions & 2 deletions src/lib/Repository/NameSchema/NameSchemaService.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType
*
* @return array
*/
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null)
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null): array
{
if ($contentType === null) {
$contentType = $this->contentTypeHandler->load($content->contentInfo->contentTypeId);
Expand Down Expand Up @@ -192,7 +192,7 @@ protected function mergeFieldMap(Content $content, array $fieldMap, array $langu
*
* @return string[]
*/
public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes)
public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array
{
list($filteredNameSchema, $groupLookupTable) = $this->filterNameSchema($nameSchema);
$tokens = $this->extractTokens($filteredNameSchema);
Expand Down
16 changes: 9 additions & 7 deletions tests/lib/Repository/Service/Mock/NameSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Ibexa\Contracts\Core\Event\ResolveUrlAliasSchemaEvent;
use Ibexa\Contracts\Core\Repository\Values\Content\Field;
use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
use Ibexa\Core\Repository\Helper\NameSchemaService;
use Ibexa\Core\Repository\NameSchema\NameSchemaService;
use Ibexa\Core\Repository\Values\Content\Content;
use Ibexa\Core\Repository\Values\Content\VersionInfo;
use Ibexa\Core\Repository\Values\ContentType\ContentType;
Expand All @@ -27,13 +27,14 @@ public function testResolveUrlAliasSchema()
$contentType = $this->buildTestContentType();

$serviceMock = $this->getMockBuilder(NameSchemaService::class)
->setMethods(['resolve'])
->setConstructorArgs(
[
$this->getPersistenceMock()->contentTypeHandler(),
$this->getContentTypeDomainMapperMock(),
$this->getFieldTypeRegistryMock(),
$this->getSchemaIdentifierExtractorMock(),
$this->getEventDispatcherMock(['field' => '<urlalias_schema>'], $content, ['<urlalias_schema>' => 42]),
$this->getEventDispatcherMock(['field' => '<urlalias_schema>'], $content, []),
]
)
->getMock();
Expand All @@ -49,13 +50,14 @@ public function testResolveUrlAliasSchemaFallbackToNameSchema()
$contentType = $this->buildTestContentType('<name_schema>', '');

$serviceMock = $this->getMockBuilder(NameSchemaService::class)
->setMethods(['resolve'])
->setConstructorArgs(
[
$this->getPersistenceMock()->contentTypeHandler(),
$this->getContentTypeDomainMapperMock(),
$this->getFieldTypeRegistryMock(),
$this->getSchemaIdentifierExtractorMock(),
$this->getEventDispatcherMock(['field' => '<name_schema>'], $content, ['<name_schema>' => null]),
$this->getEventDispatcherMock(['field' => '<name_schema>'], $content, []),
]
)
->getMock();
Expand All @@ -82,12 +84,12 @@ public function testResolveNameSchema()
$this->equalTo($content->fields),
$this->equalTo($content->versionInfo->languageCodes)
)->will(
$this->returnValue(42)
$this->returnValue([42])
);

$result = $serviceMock->resolveNameSchema($content, [], [], $contentType);

self::assertEquals(42, $result);
self::assertEquals([42], $result);
}

public function testResolveNameSchemaWithFields()
Expand Down Expand Up @@ -171,9 +173,9 @@ public function testResolve(
}

/**
* Data provider for the @return array.
* Data provider for the @see testResolve method.
*
* @see testResolve method.
* @return array
*/
public function resolveDataProvider()
{
Expand Down

0 comments on commit 0938085

Please sign in to comment.