@@ -178,22 +178,26 @@ public function testSchemaIsAddedToAttributes()
178178 $ this ->assertNotEmpty ($ attributes ['data-schema ' ]);
179179 }
180180
181- /**
182- * Ensure a source of tags matches the given string tag names
183- *
184- * @param array $expected
185- * @param DataList $actualSource
186- */
187- protected function compareTagLists (array $ expected , DataList $ actualSource )
181+ public function testPerformReadonlyTransformation ()
188182 {
189- $ actual = array_keys ($ actualSource ->map ('ID ' , 'Title ' )->toArray ());
190- sort ($ expected );
191- sort ($ actual );
192-
193- $ this ->assertEquals (
194- $ expected ,
195- $ actual
196- );
183+ $ field = new StringTagField ('Tags ' );
184+ $ field ->setSource (['Test1 ' , 'Test2 ' , 'Test3 ' ]);
185+
186+ // Ensure a single value can be rendered
187+ $ field ->setValue (['Test2 ' ]);
188+ $ field_readonly = $ field ->performReadonlyTransformation ();
189+ $ this ->assertEquals ('Test2 ' , $ field_readonly ->Value ());
190+
191+ // Ensure multiple valid values are rendered
192+ $ field ->setValue (['Test1 ' , 'Test2 ' ]);
193+ $ field_readonly = $ field ->performReadonlyTransformation ();
194+ $ this ->assertEquals ('Test1, Test2 ' , $ field_readonly ->Value ());
195+
196+ // Ensure an value not in the source array is still rendered
197+ // (because e.g. in history view it must have been a valid value when it was set)
198+ $ field ->setValue (['Test ' , 'Test1 ' ]);
199+ $ field_readonly = $ field ->performReadonlyTransformation ();
200+ $ this ->assertEquals ('Test, Test1 ' , $ field_readonly ->Value ());
197201 }
198202
199203 /**
0 commit comments