Browse Source

Using a typemap for more consistent results

Eugene Ritter 8 years ago
parent
commit
dd96a7ebba
2 changed files with 11 additions and 4 deletions
  1. 3 3
      phpunit.xml.dist
  2. 8 1
      tests/TestCase/Database/QueryTest.php

+ 3 - 3
phpunit.xml.dist

@@ -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"/>
         -->

+ 8 - 1
tests/TestCase/Database/QueryTest.php

@@ -4679,6 +4679,12 @@ class QueryTest extends TestCase
     {
         $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',
@@ -4686,10 +4692,11 @@ class QueryTest extends TestCase
                 '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);
     }
 
     /**