Skip to content

Commit

Permalink
TestConnection: Add return type to setFetchMode
Browse files Browse the repository at this point in the history
Slipped through in #88 as it's not used at all here.
Now a test exists which does.
  • Loading branch information
nilmerg committed Dec 17, 2024
1 parent b1e028b commit 919b2f2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Test/TestConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function getIterator(): \Iterator
return new \ArrayIterator([]);
}

public function setFetchMode($mode, ...$args)
public function setFetchMode($mode, ...$args): bool
{
return true;
}
};
}
Expand Down
37 changes: 37 additions & 0 deletions tests/TestConnectionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace ipl\Tests\Sql;

use ipl\Sql\Test\TestConnection;

class TestConnectionTest extends \PHPUnit\Framework\TestCase
{
public function testPrepexec()
{
$connection = new TestConnection();
$stmt = $connection->prepexec('SELECT * FROM foo');
$this->assertEmpty(iterator_to_array($stmt));
$this->assertTrue($stmt->setFetchMode(\PDO::FETCH_ASSOC));
}

public function testBeginTransaction()
{
$connection = new TestConnection();
$this->expectException(\LogicException::class);
$connection->beginTransaction();
}

public function testCommitTransaction()
{
$connection = new TestConnection();
$this->expectException(\LogicException::class);
$connection->commitTransaction();
}

public function testRollbackTransaction()
{
$connection = new TestConnection();
$this->expectException(\LogicException::class);
$connection->rollbackTransaction();
}
}

0 comments on commit 919b2f2

Please sign in to comment.