diff --git a/eZ/Publish/API/Repository/Tests/FieldType/KeywordIntegrationTest.php b/eZ/Publish/API/Repository/Tests/FieldType/KeywordIntegrationTest.php index 70a9b31ab50..4ec8c7cc0a5 100644 --- a/eZ/Publish/API/Repository/Tests/FieldType/KeywordIntegrationTest.php +++ b/eZ/Publish/API/Repository/Tests/FieldType/KeywordIntegrationTest.php @@ -9,6 +9,7 @@ namespace eZ\Publish\API\Repository\Tests\FieldType; use eZ\Publish\Core\FieldType\Keyword\Value as KeywordValue; +use eZ\Publish\API\Repository\Values\ContentType\ContentType; use eZ\Publish\API\Repository\Values\Content\Field; /** @@ -391,6 +392,49 @@ private function assertContentFieldHasCorrectData($contentId, KeywordValue $valu $this->assertEquals($value, $dataField->value); } + public function testKeywordsAreCaseSensitive() + { + $contentType = $this->testCreateContentType(); + $publishedContent01 = $this->createAndPublishContent('Foo', $contentType, md5(uniqid() . microtime())); + $publishedContent02 = $this->createAndPublishContent('foo', $contentType, md5(uniqid() . microtime())); + + $data = $publishedContent01->getField('data')->value; + $this->assertCount(1, $data->values); + $this->assertEquals('Foo', $data->values[0]); + + $data = $publishedContent02->getField('data')->value; + $this->assertCount(1, $data->values); + $this->assertEquals('foo', $data->values[0]); + } + + /** + * Create and publish content of $contentType with $fieldData. + * + * @param mixed $fieldData + * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType + * @param string $remoteId + * @return \eZ\Publish\API\Repository\Values\Content\Content + */ + protected function createAndPublishContent($fieldData, ContentType $contentType, $remoteId) + { + $repository = $this->getRepository(); + $contentService = $repository->getContentService(); + + $createStruct = $contentService->newContentCreateStruct($contentType, 'eng-US'); + $createStruct->setField('name', 'Test object'); + $createStruct->setField( + 'data', + $fieldData + ); + + $createStruct->remoteId = $remoteId; + $createStruct->alwaysAvailable = true; + + $contentDraft = $contentService->createContent($createStruct); + + return $contentService->publishVersion($contentDraft->versionInfo); + } + protected function getValidSearchValueOne() { return 'add'; diff --git a/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/LegacyStorage.php b/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/LegacyStorage.php index 5da3d0d2a31..45ff83e2fcb 100644 --- a/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/LegacyStorage.php +++ b/eZ/Publish/Core/FieldType/Keyword/KeywordStorage/Gateway/LegacyStorage.php @@ -225,6 +225,10 @@ protected function getExistingKeywords($keywordList, $contentTypeId) $existingKeywordMap = array(); foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $row) { + // filter out keywords that aren't the exact match (e.g. differ by case) + if (!in_array($row['keyword'], $keywordList)) { + continue; + } $existingKeywordMap[$row['keyword']] = $row['id']; } diff --git a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/DateAndTimeTest.php b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/DateAndTimeTest.php index 107446cd50f..b4d7b79de41 100644 --- a/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/DateAndTimeTest.php +++ b/eZ/Publish/Core/Persistence/Legacy/Tests/Content/FieldValue/Converter/DateAndTimeTest.php @@ -261,7 +261,7 @@ public function testToFieldDefinitionCurrentDate() self::assertCount(3, $fieldDef->defaultValue->data); self::assertNull($fieldDef->defaultValue->data['rfc850']); self::assertGreaterThanOrEqual($time, $fieldDef->defaultValue->data['timestamp']); - self::assertEquals($time + 1, $dateTimeFromString->getTimestamp()); + self::assertEquals($time + 1, $dateTimeFromString->getTimestamp(), 'Time does not match within 1s delta', 1); } /**