You are here

NextIdTest.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/system/src/Tests/Database/NextIdTest.php

File

core/modules/system/src/Tests/Database/NextIdTest.php
View source
<?php

/**
 * @file
 * Contains \Drupal\system\Tests\Database\NextIdTest.
 */
namespace Drupal\system\Tests\Database;

use Drupal\simpletest\KernelTestBase;

/**
 * Tests the sequences API.
 *
 * @group Database
 */
class NextIdTest extends KernelTestBase {

  /**
   * The modules to enable.
   * @var array
   */
  public static $modules = array(
    'system',
  );
  protected function setUp() {
    parent::setUp();
    $this
      ->installSchema('system', 'sequences');
  }

  /**
   * Tests that the sequences API works.
   */
  function testDbNextId() {
    $first = db_next_id();
    $second = db_next_id();

    // We can test for exact increase in here because we know there is no
    // other process operating on these tables -- normally we could only
    // expect $second > $first.
    $this
      ->assertEqual($first + 1, $second, 'The second call from a sequence provides a number increased by one.');
    $result = db_next_id(1000);
    $this
      ->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');
  }

}

Classes

Namesort descending Description
NextIdTest Tests the sequences API.