Skip to content
Permalink
Browse files

Using a typemap for more consistent results

  • Loading branch information...
T0mats0 committed Apr 4, 2018
1 parent d1cdee7 commit dd96a7ebbae878fb1b981d122841bdc1d9005492
Showing with 11 additions and 4 deletions.
  1. +3 −3 phpunit.xml.dist
  2. +8 −1 tests/TestCase/Database/QueryTest.php
@@ -50,9 +50,9 @@
<!-- Postgres
<env name="db_dsn" value="postgres://localhost/cake_test?timezone=UTC"/>
-->
<!-- Mysql
<env name="db_dsn" value="mysql://localhost/cake_test?timezone=UTC"/>
-->

<env name="db_dsn" value="mysql://root:root@localhost/cake_test?timezone=UTC"/>

<!-- SQL Server
<env name="db_dsn" value="sqlserver://localhost/cake_test?timezone=UTC"/>
-->
@@ -4679,17 +4679,24 @@ public function testFetchAssoc()
{
$this->loadFixtures('Profiles');
$query = new Query($this->connection);
$fields = [
'id' => 'integer',
'user_id' => 'integer',
'is_active' => 'boolean'
];
$typeMap = new TypeMap($fields);
$results = $query
->select([
'id',
'user_id',
'is_active'
])
->from('profiles')
->setSelectTypeMap($typeMap)
->limit(1)
->execute()
->fetchAssoc();
$this->assertSame(['id' => '1', 'user_id' => '1', 'is_active' => '0'], $results);
$this->assertSame(['id' => 1, 'user_id' => 1, 'is_active' => false], $results);
}
/**

0 comments on commit dd96a7e

Please sign in to comment.
You can’t perform that action at this time.