public function ConditionTest::testSimpleCondition in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/Database/ConditionTest.php \Drupal\Tests\Core\Database\ConditionTest::testSimpleCondition()
@covers ::compile
File
- core/
tests/ Drupal/ Tests/ Core/ Database/ ConditionTest.php, line 26 - Contains \Drupal\Tests\Core\Database\ConditionTest.
Class
- ConditionTest
- @coversDefaultClass \Drupal\Core\Database\Query\Condition
Namespace
Drupal\Tests\Core\DatabaseCode
public function testSimpleCondition() {
$connection = $this
->prophesize(Connection::class);
$connection
->escapeField('name')
->will(function ($args) {
return preg_replace('/[^A-Za-z0-9_.]+/', '', $args[0]);
});
$connection
->mapConditionOperator('=')
->willReturn([
'operator' => '=',
]);
$connection = $connection
->reveal();
$query_placeholder = $this
->prophesize(PlaceholderInterface::class);
$counter = 0;
$query_placeholder
->nextPlaceholder()
->will(function () use (&$counter) {
return $counter++;
});
$query_placeholder
->uniqueIdentifier()
->willReturn(4);
$query_placeholder = $query_placeholder
->reveal();
$condition = new Condition('AND');
$condition
->condition('name', [
'value',
]);
$condition
->compile($connection, $query_placeholder);
$this
->assertEquals(' (name = :db_condition_placeholder_0) ', $condition
->__toString());
$this
->assertEquals([
':db_condition_placeholder_0' => 'value',
], $condition
->arguments());
}