@@ -567,4 +567,49 @@ private function buildFakeResponse(): \stdClass
567
567
]
568
568
];
569
569
}
570
+
571
+ public function testNullValuesMapToGoogle ()
572
+ {
573
+ $ obj_schema = (new \GDS \Schema ('Person ' ))
574
+ ->addString ('name ' )
575
+ ->addInteger ('age ' )
576
+ ->addFloat ('weight ' )
577
+ ->addGeopoint ('location ' )
578
+ ->addDatetime ('dob ' );
579
+
580
+ $ obj_mapper = new \GDS \Mapper \RESTv1 ();
581
+ $ obj_mapper ->setSchema ($ obj_schema );
582
+
583
+ $ obj_gds_entity = new \GDS \Entity ();
584
+ $ obj_gds_entity ->setSchema ($ obj_schema );
585
+ $ obj_gds_entity ->setKind ('Person ' );
586
+
587
+ $ obj_gds_entity ->name = null ;
588
+ $ obj_gds_entity ->age = null ;
589
+ $ obj_gds_entity ->weight = null ;
590
+ $ obj_gds_entity ->location = null ;
591
+ $ obj_gds_entity ->dob = null ;
592
+
593
+ $ obj_rest_entity = $ obj_mapper ->mapToGoogle ($ obj_gds_entity );
594
+
595
+ $ this ->assertObjectHasAttribute ('name ' , $ obj_rest_entity ->properties );
596
+ $ this ->assertObjectHasAttribute ('nullValue ' , $ obj_rest_entity ->properties ->name );
597
+ $ this ->assertEquals (null , $ obj_rest_entity ->properties ->name ->nullValue );
598
+
599
+ $ this ->assertObjectHasAttribute ('age ' , $ obj_rest_entity ->properties );
600
+ $ this ->assertObjectHasAttribute ('nullValue ' , $ obj_rest_entity ->properties ->age );
601
+ $ this ->assertEquals (null , $ obj_rest_entity ->properties ->age ->nullValue );
602
+
603
+ $ this ->assertObjectHasAttribute ('weight ' , $ obj_rest_entity ->properties );
604
+ $ this ->assertObjectHasAttribute ('nullValue ' , $ obj_rest_entity ->properties ->weight );
605
+ $ this ->assertEquals (null , $ obj_rest_entity ->properties ->weight ->nullValue );
606
+
607
+ $ this ->assertObjectHasAttribute ('location ' , $ obj_rest_entity ->properties );
608
+ $ this ->assertObjectHasAttribute ('nullValue ' , $ obj_rest_entity ->properties ->location );
609
+ $ this ->assertEquals (null , $ obj_rest_entity ->properties ->location ->nullValue );
610
+
611
+ $ this ->assertObjectHasAttribute ('dob ' , $ obj_rest_entity ->properties );
612
+ $ this ->assertObjectHasAttribute ('nullValue ' , $ obj_rest_entity ->properties ->dob );
613
+ $ this ->assertEquals (null , $ obj_rest_entity ->properties ->dob ->nullValue );
614
+ }
570
615
}
0 commit comments