You are here

function InsertTest::testInsertLastInsertID in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/InsertTest.php \Drupal\system\Tests\Database\InsertTest::testInsertLastInsertID()

Tests that inserts return the proper auto-increment ID.

File

core/modules/system/src/Tests/Database/InsertTest.php, line 127
Contains \Drupal\system\Tests\Database\InsertTest.

Class

InsertTest
Tests the insert builder.

Namespace

Drupal\system\Tests\Database

Code

function testInsertLastInsertID() {
  $id = db_insert('test')
    ->fields(array(
    'name' => 'Larry',
    'age' => '30',
  ))
    ->execute();
  $this
    ->assertIdentical($id, '5', 'Auto-increment ID returned successfully.');
}