Skip to content

Commit

Permalink
Using a typemap for more consistent results
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Ritter committed Apr 4, 2018
1 parent d1cdee7 commit dd96a7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Expand Up @@ -50,9 +50,9 @@
<!-- Postgres <!-- Postgres
<env name="db_dsn" value="postgres://localhost/cake_test?timezone=UTC"/> <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 <!-- SQL Server
<env name="db_dsn" value="sqlserver://localhost/cake_test?timezone=UTC"/> <env name="db_dsn" value="sqlserver://localhost/cake_test?timezone=UTC"/>
--> -->
Expand Down
9 changes: 8 additions & 1 deletion tests/TestCase/Database/QueryTest.php
Expand Up @@ -4679,17 +4679,24 @@ public function testFetchAssoc()
{ {
$this->loadFixtures('Profiles'); $this->loadFixtures('Profiles');
$query = new Query($this->connection); $query = new Query($this->connection);
$fields = [
'id' => 'integer',
'user_id' => 'integer',
'is_active' => 'boolean'
];
$typeMap = new TypeMap($fields);
$results = $query $results = $query
->select([ ->select([
'id', 'id',
'user_id', 'user_id',
'is_active' 'is_active'
]) ])
->from('profiles') ->from('profiles')
->setSelectTypeMap($typeMap)
->limit(1) ->limit(1)
->execute() ->execute()
->fetchAssoc(); ->fetchAssoc();
$this->assertSame(['id' => '1', 'user_id' => '1', 'is_active' => '0'], $results); $this->assertSame(['id' => 1, 'user_id' => 1, 'is_active' => false], $results);
} }


/** /**
Expand Down

0 comments on commit dd96a7e

Please sign in to comment.