@@ -101,6 +101,35 @@ protected function createMultipleCountriesContent()
101101 return $ content ;
102102 }
103103
104+ /**
105+ * Create test Content with non-printable characters in name.
106+ *
107+ * @return \eZ\Publish\API\Repository\Values\Content\Content
108+ */
109+ protected function createFolderWithNonPrintableUtf8Characters ()
110+ {
111+ $ repository = $ this ->getRepository ();
112+ $ contentTypeService = $ repository ->getContentTypeService ();
113+ $ contentService = $ repository ->getContentService ();
114+
115+ $ contentType = $ contentTypeService ->loadContentTypeByIdentifier ('folder ' );
116+ $ createStruct = $ contentService ->newContentCreateStruct ($ contentType , 'eng-GB ' );
117+ $ createStruct ->remoteId = 'non-printable-char-folder-123 ' ;
118+ $ createStruct ->alwaysAvailable = false ;
119+ $ createStruct ->setField (
120+ 'name ' ,
121+ utf8_decode ("Non \x09Printable \x0EFolder " )
122+ );
123+
124+ $ locationCreateStruct = $ repository ->getLocationService ()->newLocationCreateStruct (2 );
125+ $ draft = $ contentService ->createContent ($ createStruct , [$ locationCreateStruct ]);
126+ $ content = $ contentService ->publishVersion ($ draft ->getVersionInfo ());
127+
128+ $ this ->refreshSearch ($ repository );
129+
130+ return $ content ;
131+ }
132+
104133 /**
105134 * Test for the findLocations() method.
106135 *
@@ -157,6 +186,35 @@ public function testFieldCollectionContainsNoMatch()
157186 $ this ->assertEquals (0 , $ result ->totalCount );
158187 }
159188
189+ /**
190+ * Test for the findLocations() method.
191+ *
192+ * @see \eZ\Publish\API\Repository\SearchService::findLocations()
193+ */
194+ public function testNonPrintableUtf8Characters ()
195+ {
196+ $ folder = $ this ->createFolderWithNonPrintableUtf8Characters ();
197+ $ query = new LocationQuery (
198+ [
199+ 'query ' => new Criterion \Field (
200+ 'name ' ,
201+ Criterion \Operator::EQ ,
202+ utf8_decode ("Non \x09Printable \x0EFolder " )
203+ ),
204+ ]
205+ );
206+
207+ $ repository = $ this ->getRepository ();
208+ $ searchService = $ repository ->getSearchService ();
209+ $ result = $ searchService ->findLocations ($ query );
210+
211+ $ this ->assertEquals (1 , $ result ->totalCount );
212+ $ this ->assertEquals (
213+ $ folder ->contentInfo ->mainLocationId ,
214+ $ result ->searchHits [0 ]->valueObject ->id
215+ );
216+ }
217+
160218 /**
161219 * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
162220 */
0 commit comments