-
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.
Fix
Model::__call
throwing BadMethodCallException
on empty results
* fix: fixed builder method call when fail parent::__call. * test: add test for Model::AffectedRows. * style: ./vendor/bin/php-cs-fixer fix --verbose --diff * docs: fix issue link. * refactor: I made sure not to call magic method in the parent class. * style: composer cs-fix * style: removed unnecessary variable. * docs: $this|null -> mixed
- Loading branch information
Showing
2 changed files
with
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of CodeIgniter 4 framework. | ||
* | ||
* (c) CodeIgniter Foundation <[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace CodeIgniter\Models; | ||
|
||
use Tests\Support\Models\UserModel; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class AffectedRowsTest extends LiveModelTestCase | ||
{ | ||
/** | ||
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5137 | ||
*/ | ||
public function testAffectedRowsWithEmptyUpdate(): void | ||
{ | ||
$this->createModel(UserModel::class); | ||
$notExistsId = -1; | ||
$this->model | ||
->set('country', 'US') | ||
->where('id', $notExistsId) | ||
->update(); | ||
|
||
$this->assertSame(0, $this->model->affectedRows()); | ||
} | ||
} |