22namespace Gt \DataObject \Test ;
33
44use DateTime ;
5+ use DateTimeInterface ;
56use Gt \DataObject \DataObject ;
67use PHPUnit \Framework \TestCase ;
78use stdClass ;
@@ -349,7 +350,7 @@ public function testJsonSerialize() {
349350 );
350351 }
351352
352- public function testGetArrayFixedTypes () {
353+ public function testGetArrayFixedTypeInt () {
353354 $ timestampArray = [
354355 49997 ,
355356 50000 ,
@@ -367,6 +368,67 @@ public function testGetArrayFixedTypes() {
367368 self ::assertEquals (count ($ timestampArray ), $ i + 1 );
368369 }
369370
371+ public function testGetArrayFixedTypeFloat () {
372+ $ timestampArray = [
373+ 49997.24567 ,
374+ 50000.28356 ,
375+ 49999.92846 ,
376+ 50004.89137 ,
377+ 50001.10239 ,
378+ ];
379+ $ sut = (new DataObject ())
380+ ->with ("timestamps " , $ timestampArray );
381+ $ array = $ sut ->getArray ("timestamps " , "float " );
382+ foreach ($ array as $ i => $ value ) {
383+ self ::assertIsFloat ($ value );
384+ }
385+ }
386+
387+ public function testGetArrayFixedTypeBool () {
388+ $ timestampArray = [
389+ true ,
390+ false ,
391+ true ,
392+ false ,
393+ false ,
394+ ];
395+ $ sut = (new DataObject ())
396+ ->with ("timestamps " , $ timestampArray );
397+ $ array = $ sut ->getArray ("timestamps " , "bool " );
398+ foreach ($ array as $ i => $ value ) {
399+ self ::assertIsBool ($ value );
400+ }
401+ }
402+
403+ public function testGetArrayFixedTypeString () {
404+ $ wordsArray = [
405+ "one " ,
406+ "two " ,
407+ "three " ,
408+ "four " ,
409+ "five " ,
410+ ];
411+ $ sut = (new DataObject ())
412+ ->with ("words " , $ wordsArray );
413+ $ array = $ sut ->getArray ("words " , "string " );
414+ foreach ($ array as $ i => $ value ) {
415+ self ::assertIsString ($ value );
416+ }
417+ }
418+
419+ public function testGetArrayFixedTypeDateTime () {
420+ $ dateArray = [
421+ new DateTime ("1st Jan 1970 00:00:00 " ),
422+ new DateTime ("5th Apr 1988 17:21:05 " ),
423+ ];
424+ $ sut = (new DataObject ())
425+ ->with ("dates " , $ dateArray );
426+ $ array = $ sut ->getArray ("dates " , DateTimeInterface::class);
427+ foreach ($ array as $ i => $ value ) {
428+ self ::assertInstanceOf (DateTimeInterface::class, $ value );
429+ }
430+ }
431+
370432 public function testGetArrayFixedTypesMismatch () {
371433 $ timestampArray = [
372434 49997 ,
0 commit comments