Eugene Ritter 8 years ago
parent
commit
ac6bb7fec0
1 changed files with 17 additions and 29 deletions
  1. 17 29
      tests/TestCase/Database/QueryTest.php

+ 17 - 29
tests/TestCase/Database/QueryTest.php

@@ -4708,6 +4708,12 @@ class QueryTest extends TestCase
     {
         $this->loadFixtures('Profiles');
         $query = new Query($this->connection);
+        $fields = [
+            'integer',
+            'integer',
+            'boolean'
+        ];
+        $typeMap = new TypeMap($fields);
         $query
             ->select([
                 'id',
@@ -4715,19 +4721,20 @@ class QueryTest extends TestCase
                 'is_active'
             ])
             ->from('profiles')
+            ->setSelectTypeMap($typeMap)
             ->where(['id' => 2])
             ->limit(1);
         $statement = $query->execute();
         $results = $statement->fetchColumn(0);
-        $this->assertSame('2', $results);
+        $this->assertSame(2, $results);
 
         $statement = $query->execute();
         $results = $statement->fetchColumn(1);
-        $this->assertSame('2', $results);
+        $this->assertSame(2, $results);
 
         $statement = $query->execute();
         $results = $statement->fetchColumn(2);
-        $this->assertSame('0', $results);
+        $this->assertSame(false, $results);
     }
 
     /**
@@ -4739,6 +4746,12 @@ class QueryTest extends TestCase
     {
         $this->loadFixtures('Profiles');
         $query = new Query($this->connection);
+        $fields = [
+            'integer',
+            'integer',
+            'boolean'
+        ];
+        $typeMap = new TypeMap($fields);
         $query
             ->select([
                 'id',
@@ -4746,36 +4759,11 @@ class QueryTest extends TestCase
                 'is_active'
             ])
             ->from('profiles')
+            ->setSelectTypeMap($typeMap)
             ->where(['id' => 2])
             ->limit(1);
         $statement = $query->execute();
         $results = $statement->fetchColumn(3);
         $this->assertFalse($results);
     }
-
-    /**
-     * Test that calling fetchAssoc, fetchColum and fetchObject in sequence
-     * alters the fetched data to the correct types and values.
-     * @return void
-     * @throws \Exception
-     */
-    public function testFetchAllAssocColumn()
-    {
-        $this->loadFixtures('Profiles');
-        $query = new Query($this->connection);
-        $query
-            ->select([
-                'id',
-                'user_id',
-                'is_active'
-            ])
-            ->from('profiles');
-        $statement = $query->execute();
-        $results = $statement->fetchAssoc();
-        $this->assertSame('1', $results['id']);
-        $results = $statement->fetchAssoc();
-        $this->assertSame('2', $results['id']);
-        $results = $statement->fetchColumn(0);
-        $this->assertSame('3', $results);
-    }
 }