You are here

public function UpdateTest::testPrimaryKeyUpdate in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 4.2.x tests/src/Kernel/UpdateTest.php \Drupal\Tests\sqlsrv\Kernel\UpdateTest::testPrimaryKeyUpdate()
  2. 3.0.x tests/src/Kernel/UpdateTest.php \Drupal\Tests\sqlsrv\Kernel\UpdateTest::testPrimaryKeyUpdate()
  3. 3.1.x tests/src/Kernel/UpdateTest.php \Drupal\Tests\sqlsrv\Kernel\UpdateTest::testPrimaryKeyUpdate()
  4. 4.0.x tests/src/Kernel/UpdateTest.php \Drupal\Tests\sqlsrv\Kernel\UpdateTest::testPrimaryKeyUpdate()
  5. 4.1.x tests/src/Kernel/UpdateTest.php \Drupal\Tests\sqlsrv\Kernel\UpdateTest::testPrimaryKeyUpdate()

Expect an exception when updating a primary key.

File

tests/src/Kernel/UpdateTest.php, line 17

Class

UpdateTest
Tests the update query builder.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testPrimaryKeyUpdate() {
  $this
    ->expectException(\Exception::class);
  $num_updated = $this->connection
    ->update('test')
    ->fields([
    'id' => 42,
    'name' => 'John',
  ])
    ->condition('id', '1')
    ->execute();
}