Skip to content

Commit c25142e

Browse files
committed
Fix tests
1 parent 1455361 commit c25142e

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/contracts/Repository/NameSchema/NameSchemaServiceInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,7 @@ interface NameSchemaServiceInterface
2020
{
2121
public function resolveUrlAliasSchema(Content $content, ContentType $contentType = null): array;
2222

23-
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null);
23+
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null): array;
24+
25+
public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array;
2426
}

src/lib/Repository/NameSchema/NameSchemaService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function resolveUrlAliasSchema(Content $content, ContentType $contentType
134134
*
135135
* @return array
136136
*/
137-
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null)
137+
public function resolveNameSchema(Content $content, array $fieldMap = [], array $languageCodes = [], ContentType $contentType = null): array
138138
{
139139
if ($contentType === null) {
140140
$contentType = $this->contentTypeHandler->load($content->contentInfo->contentTypeId);
@@ -192,7 +192,7 @@ protected function mergeFieldMap(Content $content, array $fieldMap, array $langu
192192
*
193193
* @return string[]
194194
*/
195-
public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes)
195+
public function resolve(string $nameSchema, ContentType $contentType, array $fieldMap, array $languageCodes): array
196196
{
197197
list($filteredNameSchema, $groupLookupTable) = $this->filterNameSchema($nameSchema);
198198
$tokens = $this->extractTokens($filteredNameSchema);

tests/lib/Repository/Service/Mock/NameSchemaTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Ibexa\Contracts\Core\Event\ResolveUrlAliasSchemaEvent;
1010
use Ibexa\Contracts\Core\Repository\Values\Content\Field;
1111
use Ibexa\Core\FieldType\TextLine\Value as TextLineValue;
12-
use Ibexa\Core\Repository\Helper\NameSchemaService;
12+
use Ibexa\Core\Repository\NameSchema\NameSchemaService;
1313
use Ibexa\Core\Repository\Values\Content\Content;
1414
use Ibexa\Core\Repository\Values\Content\VersionInfo;
1515
use Ibexa\Core\Repository\Values\ContentType\ContentType;
@@ -27,13 +27,14 @@ public function testResolveUrlAliasSchema()
2727
$contentType = $this->buildTestContentType();
2828

2929
$serviceMock = $this->getMockBuilder(NameSchemaService::class)
30+
->setMethods(['resolve'])
3031
->setConstructorArgs(
3132
[
3233
$this->getPersistenceMock()->contentTypeHandler(),
3334
$this->getContentTypeDomainMapperMock(),
3435
$this->getFieldTypeRegistryMock(),
3536
$this->getSchemaIdentifierExtractorMock(),
36-
$this->getEventDispatcherMock(['field' => '<urlalias_schema>'], $content, ['<urlalias_schema>' => 42]),
37+
$this->getEventDispatcherMock(['field' => '<urlalias_schema>'], $content, []),
3738
]
3839
)
3940
->getMock();
@@ -49,13 +50,14 @@ public function testResolveUrlAliasSchemaFallbackToNameSchema()
4950
$contentType = $this->buildTestContentType('<name_schema>', '');
5051

5152
$serviceMock = $this->getMockBuilder(NameSchemaService::class)
53+
->setMethods(['resolve'])
5254
->setConstructorArgs(
5355
[
5456
$this->getPersistenceMock()->contentTypeHandler(),
5557
$this->getContentTypeDomainMapperMock(),
5658
$this->getFieldTypeRegistryMock(),
5759
$this->getSchemaIdentifierExtractorMock(),
58-
$this->getEventDispatcherMock(['field' => '<name_schema>'], $content, ['<name_schema>' => null]),
60+
$this->getEventDispatcherMock(['field' => '<name_schema>'], $content, []),
5961
]
6062
)
6163
->getMock();
@@ -82,12 +84,12 @@ public function testResolveNameSchema()
8284
$this->equalTo($content->fields),
8385
$this->equalTo($content->versionInfo->languageCodes)
8486
)->will(
85-
$this->returnValue(42)
87+
$this->returnValue([42])
8688
);
8789

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

90-
self::assertEquals(42, $result);
92+
self::assertEquals([42], $result);
9193
}
9294

9395
public function testResolveNameSchemaWithFields()
@@ -120,12 +122,12 @@ public function testResolveNameSchemaWithFields()
120122
$this->equalTo($mergedFields),
121123
$this->equalTo($languages)
122124
)->will(
123-
$this->returnValue(42)
125+
$this->returnValue([42])
124126
);
125127

126128
$result = $serviceMock->resolveNameSchema($content, $fields, $languages, $contentType);
127129

128-
self::assertEquals(42, $result);
130+
self::assertEquals([42], $result);
129131
}
130132

131133
/**
@@ -171,9 +173,9 @@ public function testResolve(
171173
}
172174

173175
/**
174-
* Data provider for the @return array.
176+
* Data provider for the @see testResolve method.
175177
*
176-
* @see testResolve method.
178+
* @return array
177179
*/
178180
public function resolveDataProvider()
179181
{

0 commit comments

Comments
 (0)