You are here

public function ConditionTest::testNestedConditions 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/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testNestedConditions()
  2. 3.0.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testNestedConditions()
  3. 3.1.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testNestedConditions()
  4. 4.0.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testNestedConditions()
  5. 4.1.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testNestedConditions()

Confirms that we can properly nest custom conditional clauses.

File

tests/src/Kernel/ConditionTest.php, line 22

Class

ConditionTest
Test the functions of the custom Condition class.

Namespace

Drupal\Tests\sqlsrv\Kernel

Code

public function testNestedConditions() {
  $this
    ->assertEqual(true, true);
  return;

  // This query should translate to:
  // SELECT job FROM {test} WHERE name='Paul' AND (name REGEX '^P' OR age=27)
  // That should find only one record. Yes it's a non-optimal way of writing
  // that query but that's not the point!
  $query = $this->connection
    ->select('test');
  $query
    ->addField('test', 'job');
  $query
    ->condition('name', 'Paul');
  $query
    ->condition($this->connection
    ->condition('OR')
    ->condition('name', '^P', 'REGEXP')
    ->condition('age', '27'));
  $job = $query
    ->execute()
    ->fetchField();
  $this
    ->assertEqual($job, 'Songwriter', 'Correct data retrieved.');
}