-
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.
Unset
_id: null
to let it be autogenerated (#2969)
- Loading branch information
Showing
4 changed files
with
27 additions
and
2 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
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 |
---|---|---|
|
@@ -1151,4 +1151,21 @@ public function testUpdateOrCreate(array $criteria) | |
$this->assertEquals($createdAt, $checkUser->created_at->getTimestamp()); | ||
$this->assertEquals($updatedAt, $checkUser->updated_at->getTimestamp()); | ||
} | ||
|
||
public function testCreateWithNullId() | ||
{ | ||
$user = User::create(['_id' => null, 'email' => 'foo@bar']); | ||
$this->assertNotNull(ObjectId::class, $user->id); | ||
$this->assertSame(1, User::count()); | ||
} | ||
|
||
public function testUpdateOrCreateWithNullId() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('You must provide attributes to check for duplicates'); | ||
User::updateOrCreate( | ||
['_id' => null], | ||
['email' => '[email protected]'], | ||
); | ||
} | ||
} |