@@ -715,13 +715,48 @@ public function testMultipleLevelDotNotation(): void
715
715
public function testGetDirtyDates (): void
716
716
{
717
717
$ 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 ();
719
721
$ this ->assertEmpty ($ user ->getDirty ());
720
722
721
723
$ user ->birthday = new DateTime ('19 august 1989 ' );
722
724
$ this ->assertEmpty ($ user ->getDirty ());
723
725
}
724
726
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
+
725
760
public function testChunkById (): void
726
761
{
727
762
User::create (['name ' => 'fork ' , 'tags ' => ['sharp ' , 'pointy ' ]]);
0 commit comments