Added testing
This commit is contained in:
26
tests/ResultSetTest.php
Normal file
26
tests/ResultSetTest.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use ProVM\Database\ResultSet;
|
||||
|
||||
class ResultSetTest extends TestCase
|
||||
{
|
||||
public function testResultSet()
|
||||
{
|
||||
$result1 = ['col1', 'col2', 'col3'];
|
||||
$result2 = [['col1', 'col2'], ['col3', 'col4']];
|
||||
|
||||
$statement = $this->getMockBuilder(PDOStatement::class)->getMock();
|
||||
$statement->method('execute')->willReturn(true);
|
||||
$statement->method('fetch')->willReturn($result1);
|
||||
$statement->method('fetchAll')->willReturn($result2);
|
||||
$statement->method('rowCount')->willReturn(2);
|
||||
|
||||
$resultSet = new ResultSet($statement);
|
||||
|
||||
$resultSet->execute(['foo' => 'bar']);
|
||||
$this->assertTrue(true);
|
||||
$this->assertEquals($result1, $resultSet->fetchFirst());
|
||||
$this->assertEquals($result2, $resultSet->fetchAll());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user