@@ -715,13 +715,48 @@ public function testMultipleLevelDotNotation(): void
715715 public function testGetDirtyDates (): void
716716 {
717717 $ user = new User ();
718- $ user ->setRawAttributes (['name ' => 'John Doe ' , 'birthday ' => new DateTime ('19 august 1989 ' )], true );
718+ $ user ->name = 'John Doe ' ;
719+ $ user ->birthday = new DateTime ('19 august 1989 ' );
720+ $ user ->syncOriginal ();
719721 $ this ->assertEmpty ($ user ->getDirty ());
720722
721723 $ user ->birthday = new DateTime ('19 august 1989 ' );
722724 $ this ->assertEmpty ($ user ->getDirty ());
723725 }
724726
727+ public function testGetDirty ()
728+ {
729+ $ user = new User ([
730+ 'name ' => 'John Doe ' ,
731+ 'email ' => 'john.doe@example.com ' ,
732+ 'phone ' => '123456789 ' ,
733+ ]);
734+
735+ $ user ->save ();
736+
737+ $ this ->assertFalse ($ user ->isDirty ());
738+
739+ $ user ->phone = '1234555555 ' ;
740+ $ this ->assertTrue ($ user ->isDirty ());
741+
742+ $ dirty = $ user ->getDirty ();
743+ $ this ->assertArrayHasKey ('phone ' , $ dirty );
744+ $ this ->assertEquals ('1234555555 ' , $ dirty ['phone ' ]);
745+
746+ $ user ->email = 'jane.doe@example.com ' ;
747+ $ this ->assertTrue ($ user ->isDirty ());
748+ $ dirty = $ user ->getDirty ();
749+ $ this ->assertArrayHasKey ('phone ' , $ dirty );
750+ $ this ->assertArrayHasKey ('email ' , $ dirty );
751+ $ this ->assertEquals ('1234555555 ' , $ dirty ['phone ' ]);
752+ $ this ->assertEquals ('jane.doe@example.com ' , $ dirty ['email ' ]);
753+
754+ $ user ->save ();
755+
756+ $ this ->assertFalse ($ user ->isDirty ());
757+ $ this ->assertEmpty ($ user ->getDirty ());
758+ }
759+
725760 public function testChunkById (): void
726761 {
727762 User::create (['name ' => 'fork ' , 'tags ' => ['sharp ' , 'pointy ' ]]);
0 commit comments