class EmptyStatementTest

Tests the empty pseudo-statement class.

Hierarchy

Expanded class hierarchy of EmptyStatementTest

File

drupal/core/tests/Drupal/Tests/Core/Database/EmptyStatementTest.php, line 17
Definition of Drupal\system\Tests\Database\EmptyStatementTest.

Namespace

Drupal\Tests\Core\Database
View source
class EmptyStatementTest extends UnitTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Empty statement',
      'description' => 'Test the empty pseudo-statement class.',
      'group' => 'Database',
    );
  }

  /**
   * Tests that the empty result set behaves as empty.
   */
  function testEmpty() {
    $result = new StatementEmpty();
    $this
      ->assertTrue($result instanceof StatementInterface, 'Class implements expected interface');
    $this
      ->assertNull($result
      ->fetchObject(), 'Null result returned.');
  }

  /**
   * Tests that the empty result set iterates safely.
   */
  function testEmptyIteration() {
    $result = new StatementEmpty();
    foreach ($result as $record) {
      $this
        ->fail('Iterating empty result set should not iterate.');
      return;
    }
  }

  /**
   * Tests that the empty result set mass-fetches in an expected way.
   */
  function testEmptyFetchAll() {
    $result = new StatementEmpty();
    $this
      ->assertEquals($result
      ->fetchAll(), array(), 'Empty array returned from empty result set.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EmptyStatementTest::getInfo public static function This method exists to support the simpletest UI runner. Overrides UnitTestCase::getInfo
EmptyStatementTest::testEmpty function Tests that the empty result set behaves as empty.
EmptyStatementTest::testEmptyFetchAll function Tests that the empty result set mass-fetches in an expected way.
EmptyStatementTest::testEmptyIteration function Tests that the empty result set iterates safely.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::randomName public static function Generates a random string containing letters and numbers.