Version 1
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Database / NextIdTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Database;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests the sequences API.
9  *
10  * @group Database
11  */
12 class NextIdTest extends KernelTestBase {
13
14   /**
15    * The modules to enable.
16    * @var array
17    */
18   public static $modules = ['system'];
19
20   protected function setUp() {
21     parent::setUp();
22     $this->installSchema('system', 'sequences');
23   }
24
25   /**
26    * Tests that the sequences API works.
27    */
28   public function testDbNextId() {
29     $first = db_next_id();
30     $second = db_next_id();
31     // We can test for exact increase in here because we know there is no
32     // other process operating on these tables -- normally we could only
33     // expect $second > $first.
34     $this->assertEqual($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
35     $result = db_next_id(1000);
36     $this->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');
37   }
38
39 }