Skip to content
Permalink
Browse files

Updated and fixed type-o in tests.

  • Loading branch information...
T0mats0 committed Apr 3, 2018
1 parent 9c89740 commit a93b0ff5be094247544d801837edc739a119d529
@@ -96,9 +96,6 @@ public function fetch($type = parent::FETCH_TYPE_NUM)
if ($type === static::FETCH_TYPE_ASSOC) {
return $this->_statement->fetch(PDO::FETCH_ASSOC);
}
if ($type === static::FETCH_TYPE_OBJ) {
return $this->_statement->fetch(PDO::FETCH_OBJ);
}
return $this->_statement->fetch($type);
}
@@ -125,9 +122,6 @@ public function fetchAll($type = parent::FETCH_TYPE_NUM)
if ($type === static::FETCH_TYPE_ASSOC) {
return $this->_statement->fetchAll(PDO::FETCH_ASSOC);
}
if ($type === static::FETCH_TYPE_OBJ) {
return $this->_statement->fetchAll(PDO::FETCH_OBJ);
}
return $this->_statement->fetchAll($type);
}
@@ -210,6 +210,9 @@ public function fetch($type = self::FETCH_TYPE_NUM)
}
/**
* Returns the next row in a result set as an associative array. Calling this function is the same as calling
* $statement->fetch(StatementDecorator::FETCH_TYPE_ASSOC). If no results are found false is returned.
*
* @return array|false Result array containing columns and values an an associative array or false if no results
*/
public function fetchAssoc()
@@ -4723,6 +4723,29 @@ public function testFetchColumn()
$this->assertSame('0', $results);
}
/**
* Test that fetchColumn() will return false if $position is not set.
* @throws \Exception
* @return void
*/
public function testFetchColumnReturnsFalse()
{
$this->loadFixtures('Profiles');
$query = new Query($this->connection);
$query
->select([
'id',
'user_id',
'is_active'
])
->from('profiles')
->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.
@@ -4746,6 +4769,6 @@ public function testFetchAllAssocColumn()
$results = $statement->fetchAssoc();
$this->assertSame('2', $results['id']);
$results = $statement->fetchColumn(0);
$this->assertSame('3', $results[0]);
$this->assertSame('3', $results);
}
}

0 comments on commit a93b0ff

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