function QueryTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest::setUp()
  2. 8.9.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest::setUp()
  3. 10 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php, line 30

Class

QueryTest
@coversDefaultClass \Drupal\Core\Entity\Query\Sql\Query @group Entity

Namespace

Drupal\Tests\Core\Entity\Query\Sql

Code

protected function setUp() : void {
    parent::setUp();
    $entity_type = new EntityType([
        'id' => 'example_entity_query',
    ]);
    $conjunction = 'AND';
    $connection = $this->getMockBuilder('Drupal\\Core\\Database\\Connection')
        ->disableOriginalConstructor()
        ->getMock();
    $namespaces = [
        'Drupal\\Core\\Entity\\Query\\Sql',
    ];
    $this->query = new Query($entity_type, $conjunction, $connection, $namespaces);
    $container = $this->createMock(ContainerInterface::class);
    $container->expects($this->any())
        ->method('get')
        ->with('module_handler')
        ->willReturn($this->createMock(ModuleHandler::class));
    \Drupal::setContainer($container);
}

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