diff --git a/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php b/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php index 168f95ce9e..b47ebef256 100644 --- a/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php +++ b/src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php @@ -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; } diff --git a/src/lib/Repository/NameSchema/NameSchemaService.php b/src/lib/Repository/NameSchema/NameSchemaService.php index fa59a4dffd..e89ddacf93 100644 --- a/src/lib/Repository/NameSchema/NameSchemaService.php +++ b/src/lib/Repository/NameSchema/NameSchemaService.php @@ -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); @@ -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); diff --git a/tests/lib/Repository/Service/Mock/NameSchemaTest.php b/tests/lib/Repository/Service/Mock/NameSchemaTest.php index 750b3ff0a1..e00c71fb2e 100644 --- a/tests/lib/Repository/Service/Mock/NameSchemaTest.php +++ b/tests/lib/Repository/Service/Mock/NameSchemaTest.php @@ -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; @@ -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' => ''], $content, ['' => 42]), + $this->getEventDispatcherMock(['field' => ''], $content, []), ] ) ->getMock(); @@ -49,13 +50,14 @@ public function testResolveUrlAliasSchemaFallbackToNameSchema() $contentType = $this->buildTestContentType('', ''); $serviceMock = $this->getMockBuilder(NameSchemaService::class) + ->setMethods(['resolve']) ->setConstructorArgs( [ $this->getPersistenceMock()->contentTypeHandler(), $this->getContentTypeDomainMapperMock(), $this->getFieldTypeRegistryMock(), $this->getSchemaIdentifierExtractorMock(), - $this->getEventDispatcherMock(['field' => ''], $content, ['' => null]), + $this->getEventDispatcherMock(['field' => ''], $content, []), ] ) ->getMock(); @@ -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() @@ -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() {