-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #16468 from niden/T16467-column-0-to-array
T16467 column 0 to array
- Loading branch information
Showing
3 changed files
with
80 additions
and
14 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
|
||
use DatabaseTester; | ||
use PDO; | ||
use Phalcon\Mvc\Model\Manager; | ||
use Phalcon\Tests\Fixtures\Migrations\InvoicesMigration; | ||
use Phalcon\Tests\Fixtures\Traits\DiTrait; | ||
use Phalcon\Tests\Models\Invoices; | ||
|
@@ -247,7 +248,7 @@ public function mvcModelToArrayFindCastOnHydrateForceCasting(DatabaseTester $I) | |
'inv_title' => $title, | ||
'inv_total' => 222.19, | ||
'inv_created_at' => $date, | ||
] | ||
], | ||
]; | ||
$actual = $invoices->toArray(); | ||
$I->assertSame($expected, $actual); | ||
|
@@ -259,4 +260,66 @@ public function mvcModelToArrayFindCastOnHydrateForceCasting(DatabaseTester $I) | |
] | ||
); | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Mvc\Model :: toArray() - execute column not in columnMap | ||
* | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2022-11-21 | ||
* | ||
* @issue https://github.com/phalcon/cphalcon/issues/16467 | ||
* | ||
* @group mysql | ||
*/ | ||
public function mvcModelToArrayExecuteColumnNotInColumnMap(DatabaseTester $I) | ||
{ | ||
$I->wantToTest('Mvc\Model - toArray() - execute - column not in columnMap'); | ||
|
||
/** @var PDO $connection */ | ||
$connection = $I->getConnection(); | ||
$title = uniqid('inv-'); | ||
$date = date('Y-m-d H:i:s'); | ||
|
||
$migration = new InvoicesMigration($connection); | ||
$migration->insert(4, 1, 0, $title, 111.26, $date); | ||
$migration->insert(5, 2, 1, $title, 222.19, $date); | ||
|
||
$manager = $this->getService('modelsManager'); | ||
$class = Manager::class; | ||
$I->assertInstanceOf($class, $manager); | ||
|
||
|
||
$result = $manager | ||
->createBuilder() | ||
->addFrom(InvoicesMap::class, 'i') | ||
->limit(10) | ||
->getQuery() | ||
->execute() | ||
; | ||
|
||
$result->rewind(); | ||
$result->next(); | ||
$result->rewind(); | ||
|
||
$expected = [ | ||
[ | ||
'id' => 4, | ||
'cst_id' => 1, | ||
'status_flag' => 0, | ||
'title' => $title, | ||
'total' => 111.26, | ||
'created_at' => $date, | ||
], | ||
[ | ||
'id' => 5, | ||
'cst_id' => 2, | ||
'status_flag' => 1, | ||
'title' => $title, | ||
'total' => 222.19, | ||
'created_at' => $date, | ||
], | ||
]; | ||
$actual = $result->toArray(); | ||
$I->assertSame($expected, $actual); | ||
} | ||
} |