public function ConditionTest::testLikeWithBrackets in Drupal driver for SQL Server and SQL Azure 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testLikeWithBrackets()
- 4.2.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testLikeWithBrackets()
- 3.1.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testLikeWithBrackets()
- 4.0.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testLikeWithBrackets()
- 4.1.x tests/src/Kernel/ConditionTest.php \Drupal\Tests\sqlsrv\Kernel\ConditionTest::testLikeWithBrackets()
Test that brackets are escaped correctly.
File
- tests/
src/ Kernel/ ConditionTest.php, line 102
Class
- ConditionTest
- Test the functions of the custom Condition class.
Namespace
Drupal\Tests\sqlsrv\KernelCode
public function testLikeWithBrackets() {
$this->connection
->insert('test_people')
->fields([
'job' => '[Rutles] - Guitar',
'name' => 'Dirk',
])
->execute();
$name = $this->connection
->select('test_people', 't')
->fields('t', [
'name',
])
->condition('job', '%[Rutles%', 'LIKE')
->execute()
->fetchField();
$this
->assertEqual('Dirk', $name);
$this->connection
->insert('test_people')
->fields([
'job' => '[Rutles] - Drummer [Original]',
'name' => 'Kevin',
])
->execute();
$names = $this->connection
->select('test_people', 't')
->fields('t', [
'name',
'job',
])
->condition('job', '%[Rutles]%', 'LIKE')
->execute()
->fetchAllAssoc('job');
$this
->assertCount(2, $names);
}