Skip to content

Commit

Permalink
#16307 - Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Jun 30, 2023
1 parent f05d584 commit 8506bbc
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/database/Mvc/Model/FindCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,41 @@ public function mvcModelFindPrivatePropertyWithRedisCache(DatabaseTester $I)
$result = $cache->delete($cacheKey);
$I->assertTrue($result);
}

/**
* Tests Phalcon\Mvc\Model :: find() - specific column
*
* @author Phalcon Team <team@phalcon.io>
* @since 2023-06-30
*
* @group mysql
* @group pgsql
* @group sqlite
*/
public function mvcModelFindWithSpecificColumn(DatabaseTester $I)
{
$I->wantToTest('Mvc\Model - find() - with specific column');

/** @var PDO $connection */
$connection = $I->getConnection();
$migration = new ObjectsMigration($connection);
$migration->insert(1, 'random data', 1);
$migration->insert(2, 'random data 2', 1);
$migration->insert(4, 'random data 4', 1);

/**
* Get the records (should cache the resultset)
*/
$data = Objects::find(
[
'columns' => 'obj_id',
'conditions' => 'obj_id IN ({ids:array})',
'bind' => ['ids' => [1, 2, 3]],
]
);

$I->assertEquals(2, count($data));
$I->assertEquals(1, $data[0]->obj_id);
$I->assertEquals(2, $data[1]->obj_id);
}
}

0 comments on commit 8506bbc

Please sign in to comment.