3 namespace Drupal\Tests\Core\Database;
5 use Drupal\Core\Database\StatementEmpty;
6 use Drupal\Core\Database\StatementInterface;
7 use Drupal\Tests\UnitTestCase;
10 * Tests the empty pseudo-statement class.
14 class EmptyStatementTest extends UnitTestCase {
16 * Tests that the empty result set behaves as empty.
18 public function testEmpty() {
19 $result = new StatementEmpty();
21 $this->assertTrue($result instanceof StatementInterface, 'Class implements expected interface');
22 $this->assertNull($result->fetchObject(), 'Null result returned.');
26 * Tests that the empty result set iterates safely.
28 public function testEmptyIteration() {
29 $result = new StatementEmpty();
30 $this->assertSame(0, iterator_count($result), 'Empty result set should not iterate.');
34 * Tests that the empty result set mass-fetches in an expected way.
36 public function testEmptyFetchAll() {
37 $result = new StatementEmpty();
39 $this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');