@@ -250,6 +250,43 @@ public function it_propagates_origin_date_to_descendent_models()
250
250
$ this ->assertEquals ($ entry ->descendants ()->get ('fr ' )->model ()->date , '2024-01-01 00:00:00 ' );
251
251
}
252
252
253
+ #[Test]
254
+ public function it_localizes_null_fields ()
255
+ {
256
+ $ this ->setSites ([
257
+ 'en ' => ['name ' => 'English ' , 'locale ' => 'en_US ' , 'url ' => 'http://test.com/ ' ],
258
+ 'fr ' => ['name ' => 'French ' , 'locale ' => 'fr_FR ' , 'url ' => 'http://fr.test.com/ ' ],
259
+ 'es ' => ['name ' => 'Spanish ' , 'locale ' => 'es_ES ' , 'url ' => 'http://test.com/es/ ' ],
260
+ 'de ' => ['name ' => 'German ' , 'locale ' => 'de_DE ' , 'url ' => 'http://test.com/de/ ' ],
261
+ ]);
262
+
263
+ $ blueprint = Facades \Blueprint::makeFromFields (['foo ' => ['type ' => 'text ' , 'localizable ' => true ]])->setHandle ('test ' );
264
+ $ blueprint ->save ();
265
+
266
+ BlueprintRepository::shouldReceive ('in ' )->with ('collections/pages ' )->andReturn (collect (['test ' => $ blueprint ]));
267
+
268
+ $ collection = (new Collection )
269
+ ->handle ('pages ' )
270
+ ->propagate (true )
271
+ ->sites (['en ' , 'fr ' , 'es ' , 'de ' ])
272
+ ->save ();
273
+
274
+ $ entry = (new Entry )
275
+ ->id (1 )
276
+ ->locale ('en ' )
277
+ ->collection ($ collection )
278
+ ->blueprint ('test ' )
279
+ ->data (['foo ' => 'bar ' ]);
280
+
281
+ $ entry ->save ();
282
+ $ entry ->descendants ()->get ('fr ' )->data (['foo ' => null ])->save ();
283
+ $ entry ->descendants ()->get ('es ' )->data (['foo ' => 'baz ' ])->save ();
284
+
285
+ $ this ->assertNull ($ entry ->descendants ()->get ('fr ' )->foo ?? null );
286
+ $ this ->assertEquals ('bar ' , $ entry ->descendants ()->get ('de ' )->foo ?? null );
287
+ $ this ->assertEquals ('baz ' , $ entry ->descendants ()->get ('es ' )->foo ?? null );
288
+ }
289
+
253
290
#[Test]
254
291
public function it_stores_and_retrieves_mapped_data_values ()
255
292
{
0 commit comments