EmptyStatementTest.php
Same filename in other branches
Namespace
Drupal\Tests\Core\DatabaseFile
-
core/
tests/ Drupal/ Tests/ Core/ Database/ EmptyStatementTest.php
View source
<?php
namespace Drupal\Tests\Core\Database;
use Drupal\Core\Database\StatementEmpty;
use Drupal\Core\Database\StatementInterface;
use Drupal\Tests\UnitTestCase;
/**
* Tests the empty pseudo-statement class.
*
* @group Database
*/
class EmptyStatementTest extends UnitTestCase {
/**
* Tests that the empty result set behaves as empty.
*/
public function testEmpty() {
$result = new StatementEmpty();
$this->assertInstanceOf(StatementInterface::class, $result);
$this->assertNull($result->fetchObject(), 'Null result returned.');
}
/**
* Tests that the empty result set iterates safely.
*/
public function testEmptyIteration() {
$result = new StatementEmpty();
$this->assertSame(0, iterator_count($result), 'Empty result set should not iterate.');
}
/**
* Tests that the empty result set mass-fetches in an expected way.
*/
public function testEmptyFetchAll() {
$result = new StatementEmpty();
$this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
EmptyStatementTest | Tests the empty pseudo-statement class. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.