You are here

public function ConditionTest::testContribCondition in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Database/ConditionTest.php \Drupal\Tests\Core\Database\ConditionTest::testContribCondition()
  2. 9 core/tests/Drupal/Tests/Core/Database/ConditionTest.php \Drupal\Tests\Core\Database\ConditionTest::testContribCondition()

Tests that the core Condition can be overridden.

File

core/tests/Drupal/Tests/Core/Database/ConditionTest.php, line 186

Class

ConditionTest
@coversDefaultClass \Drupal\Core\Database\Query\Condition

Namespace

Drupal\Tests\Core\Database

Code

public function testContribCondition() {
  $mockCondition = $this
    ->getMockBuilder(Condition::class)
    ->setMockClassName('MockCondition')
    ->setConstructorArgs([
    NULL,
  ])
    ->disableOriginalConstructor()
    ->getMock();
  $contrib_namespace = 'Drupal\\mock\\Driver\\Database\\mock';
  $mocked_namespace = $contrib_namespace . '\\Condition';
  class_alias('MockCondition', $mocked_namespace);
  $options['namespace'] = $contrib_namespace;
  $options['prefix'] = '';
  $mockPdo = $this
    ->createMock(StubPDO::class);
  $connection = new StubConnection($mockPdo, $options);
  $condition = $connection
    ->condition('AND');
  $this
    ->assertSame('MockCondition', get_class($condition));
}