-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: use mongodb function to check for dirtiness
Co-Authored-By: Jérôme Tamarelle <[email protected]> Co-Authored-By: Hamid Alaei Varnosfaderani <[email protected]>
- Loading branch information
1 parent
e652b0c
commit ee5494b
Showing
3 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -876,13 +876,48 @@ public function testMultipleLevelDotNotation(): void | |
public function testGetDirtyDates(): void | ||
{ | ||
$user = new User(); | ||
$user->setRawAttributes(['name' => 'John Doe', 'birthday' => new DateTime('19 august 1989')], true); | ||
$user->name = 'John Doe'; | ||
$user->birthday = new DateTime('19 august 1989'); | ||
$user->syncOriginal(); | ||
$this->assertEmpty($user->getDirty()); | ||
|
||
$user->birthday = new DateTime('19 august 1989'); | ||
$this->assertEmpty($user->getDirty()); | ||
} | ||
|
||
public function testGetDirty() | ||
{ | ||
$user = new User([ | ||
'name' => 'John Doe', | ||
'email' => '[email protected]', | ||
'phone' => '123456789', | ||
]); | ||
|
||
$user->save(); | ||
|
||
$this->assertFalse($user->isDirty()); | ||
|
||
$user->phone = '1234555555'; | ||
$this->assertTrue($user->isDirty()); | ||
|
||
$dirty = $user->getDirty(); | ||
$this->assertArrayHasKey('phone', $dirty); | ||
$this->assertEquals('1234555555', $dirty['phone']); | ||
|
||
$user->email = '[email protected]'; | ||
$this->assertTrue($user->isDirty()); | ||
$dirty = $user->getDirty(); | ||
$this->assertArrayHasKey('phone', $dirty); | ||
$this->assertArrayHasKey('email', $dirty); | ||
$this->assertEquals('1234555555', $dirty['phone']); | ||
$this->assertEquals('[email protected]', $dirty['email']); | ||
|
||
$user->save(); | ||
|
||
$this->assertFalse($user->isDirty()); | ||
$this->assertEmpty($user->getDirty()); | ||
} | ||
|
||
public function testChunkById(): void | ||
{ | ||
User::create(['name' => 'fork', 'tags' => ['sharp', 'pointy']]); | ||
|