You are here

public function OrderByTest::testFieldEscaping in Drupal driver for SQL Server and SQL Azure 8.2

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

Tests that fields passed for ordering get escaped properly.

File

tests/src/Unit/OrderByTest.php, line 51

Class

OrderByTest
Tests the orderBy() method of select queries.

Namespace

Drupal\Tests\sqlsrv\Unit

Code

public function testFieldEscaping() {
  $this->query
    ->orderBy('x; DROP table node; --');
  $sql = $this->query
    ->__toString();
  $this
    ->assertStringEndsWith('ORDER BY [xDROPtablenode] ASC', $sql, 'Order by field is escaped correctly.');
}