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 {
17 * Tests that the empty result set behaves as empty.
19 public function testEmpty() {
20 $result = new StatementEmpty();
22 $this->assertTrue($result instanceof StatementInterface, 'Class implements expected interface');
23 $this->assertNull($result->fetchObject(), 'Null result returned.');
27 * Tests that the empty result set iterates safely.
29 public function testEmptyIteration() {
30 $result = new StatementEmpty();
31 $this->assertSame(0, iterator_count($result), 'Empty result set should not iterate.');
35 * Tests that the empty result set mass-fetches in an expected way.
37 public function testEmptyFetchAll() {
38 $result = new StatementEmpty();
40 $this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');