Added testing

This commit is contained in:
2024-04-22 11:56:36 -04:00
parent 99344fda7d
commit 96d0232d78
13 changed files with 287 additions and 4 deletions

26
tests/ResultSetTest.php Normal file
View 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());
}
}