function ConnectionTest::testCondition

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest::testCondition()
  2. 10 core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest::testCondition()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php \Drupal\KernelTests\Core\Database\ConnectionTest::testCondition()

Test that the method ::condition() returns a Condition object.

File

core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php, line 166

Class

ConnectionTest
Tests of the core database system.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testCondition() {
    $connection = Database::getConnection('default', 'default');
    $namespace = (new \ReflectionObject($connection))->getNamespaceName() . "\\Condition";
    if (!class_exists($namespace)) {
        $namespace = Condition::class;
    }
    $condition = $connection->condition('AND');
    $this->assertSame($namespace, get_class($condition));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.