Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Database / EmptyStatementTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Database;
4
5 use Drupal\Core\Database\StatementEmpty;
6 use Drupal\Core\Database\StatementInterface;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * Tests the empty pseudo-statement class.
11  *
12  * @group Database
13  */
14 class EmptyStatementTest extends UnitTestCase {
15
16   /**
17    * Tests that the empty result set behaves as empty.
18    */
19   public function testEmpty() {
20     $result = new StatementEmpty();
21
22     $this->assertTrue($result instanceof StatementInterface, 'Class implements expected interface');
23     $this->assertNull($result->fetchObject(), 'Null result returned.');
24   }
25
26   /**
27    * Tests that the empty result set iterates safely.
28    */
29   public function testEmptyIteration() {
30     $result = new StatementEmpty();
31     $this->assertSame(0, iterator_count($result), 'Empty result set should not iterate.');
32   }
33
34   /**
35    * Tests that the empty result set mass-fetches in an expected way.
36    */
37   public function testEmptyFetchAll() {
38     $result = new StatementEmpty();
39
40     $this->assertEquals($result->fetchAll(), [], 'Empty array returned from empty result set.');
41   }
42
43 }