-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8670 from kenjis/fix-model-set-entity
fix: Model::set() does not accept object
- Loading branch information
Showing
3 changed files
with
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -378,6 +378,51 @@ public function testUpdateWithEntityNoAllowedFields(): void | |
$this->model->update($id, $entity); | ||
} | ||
|
||
public function testUpdateSetObject(): void | ||
{ | ||
$this->createModel(UserModel::class); | ||
|
||
$object = new stdClass(); | ||
$object->name = 'Jones Martin'; | ||
$object->email = '[email protected]'; | ||
$object->country = 'India'; | ||
|
||
/** @var int|string $id */ | ||
$id = $this->model->insert($object); | ||
|
||
/** @var stdClass $object */ | ||
$object = $this->model->find($id); | ||
$object->name = 'John Smith'; | ||
|
||
$return = $this->model->where('id', $id)->set($object)->update(); | ||
|
||
$this->assertTrue($return); | ||
} | ||
|
||
public function testUpdateSetEntity(): void | ||
{ | ||
$this->createModel(UserModel::class); | ||
|
||
$object = new stdClass(); | ||
$object->id = 1; | ||
$object->name = 'Jones Martin'; | ||
$object->email = '[email protected]'; | ||
$object->country = 'India'; | ||
|
||
$id = $this->model->insert($object); | ||
|
||
$entity = new Entity([ | ||
'id' => 1, | ||
'name' => 'John Smith', | ||
'email' => '[email protected]', | ||
'country' => 'India', | ||
]); | ||
|
||
$return = $this->model->where('id', $id)->set($entity)->update(); | ||
|
||
$this->assertTrue($return); | ||
} | ||
|
||
public function testUpdateEntityWithPrimaryKeyCast(): void | ||
{ | ||
if ( | ||
|