@@ -475,12 +475,41 @@ public function throwsExceptionWithInvalidColor(string $color): void
475475 /**
476476 * @test
477477 */
478- public function getArrayRepresentationThrowsException (): void
478+ public function getArrayRepresentationIncludesClassName (): void
479479 {
480- $ this -> expectException (\BadMethodCallException::class );
480+ $ subject = new Color ([ ' r ' => ' 10 ' , ' g ' => ' 20 ' , ' b ' => ' 30 ' ] );
481481
482- $ subject = new Color ([] );
482+ $ result = $ subject -> getArrayRepresentation ( );
483483
484- $ subject ->getArrayRepresentation ();
484+ self ::assertSame ('Color ' , $ result ['class ' ]);
485+ }
486+
487+ /**
488+ * @test
489+ */
490+ public function getArrayRepresentationIncludesValueKeysAsName (): void
491+ {
492+ $ subject = new Color (['r ' => '10 ' , 'g ' => '20 ' , 'b ' => '30 ' ]);
493+
494+ $ result = $ subject ->getArrayRepresentation ();
495+
496+ self ::assertSame ('rgb ' , $ result ['name ' ]);
497+ }
498+
499+ /**
500+ * @test
501+ */
502+ public function getArrayRepresentationIncludesValueAsComponents (): void
503+ {
504+ $ subject = new Color (['r ' => '10 ' , 'g ' => '20 ' , 'b ' => '30 ' ]);
505+
506+ $ result = $ subject ->getArrayRepresentation ();
507+
508+ $ expected = [
509+ 'r ' => ['class ' => 'string ' , 'value ' => '10 ' ],
510+ 'g ' => ['class ' => 'string ' , 'value ' => '20 ' ],
511+ 'b ' => ['class ' => 'string ' , 'value ' => '30 ' ],
512+ ];
513+ self ::assertSame ($ expected , $ result ['components ' ]);
485514 }
486515}
0 commit comments