diff --git a/tests/TestCase/Database/QueryTest.php b/tests/TestCase/Database/QueryTest.php index e117a8f6071..4ad54da4614 100644 --- a/tests/TestCase/Database/QueryTest.php +++ b/tests/TestCase/Database/QueryTest.php @@ -4708,6 +4708,12 @@ public function testFetchColumn() { $this->loadFixtures('Profiles'); $query = new Query($this->connection); + $fields = [ + 'integer', + 'integer', + 'boolean' + ]; + $typeMap = new TypeMap($fields); $query ->select([ 'id', @@ -4715,19 +4721,20 @@ public function testFetchColumn() '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 @@ public function testFetchColumnReturnsFalse() { $this->loadFixtures('Profiles'); $query = new Query($this->connection); + $fields = [ + 'integer', + 'integer', + 'boolean' + ]; + $typeMap = new TypeMap($fields); $query ->select([ 'id', @@ -4746,36 +4759,11 @@ public function testFetchColumnReturnsFalse() '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); - } }