Same filename in this branch
- 10 core/modules/views_ui/tests/src/Functional/QueryTest.php
- 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
- 10 core/modules/views/tests/src/Kernel/Plugin/QueryTest.php
- 10 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
- 10 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php
Same filename and directory in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
- 9 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
Namespace
Drupal\Tests\Core\Entity\Query\Sql
File
core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\Core\Entity\Query\Sql;
use Drupal\Core\Entity\EntityType;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Entity\Query\QueryException;
use Drupal\Core\Entity\Query\Sql\Query;
use Symfony\Component\DependencyInjection\ContainerInterface;
class QueryTest extends UnitTestCase {
protected $query;
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')
->will($this
->returnValue($this
->createMock(ModuleHandler::class)));
\Drupal::setContainer($container);
}
public function testNoBaseTable() {
$this
->expectException(QueryException::class);
$this
->expectExceptionMessage('No base table for example_entity_query, invalid query.');
$this->query
->execute();
}
public function testNoRevisionTable() {
$this
->expectException(QueryException::class);
$this
->expectExceptionMessage('No revision table for example_entity_query, invalid query.');
$this->query
->allRevisions()
->execute();
}
}
Classes