class QueryTest
Tests Drupal\Core\Entity\Query\Sql\Query.
Attributes
#[CoversClass(Query::class)]
#[Group('Entity')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Entity\Query\Sql\QueryTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of QueryTest
1 string reference to 'QueryTest'
- QueryTest::calculateDependencies in core/
modules/ views/ tests/ modules/ views_test_data/ src/ Plugin/ views/ query/ QueryTest.php - Calculates dependencies for the configured plugin.
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ Query/ Sql/ QueryTest.php, line 19
Namespace
Drupal\Tests\Core\Entity\Query\SqlView source
class QueryTest extends UnitTestCase {
/**
* The query object.
*
* @var \Drupal\Core\Entity\Query\Sql\Query
*/
protected $query;
/**
* {@inheritdoc}
*/
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);
}
/**
* Tests entity query for entity type without base table.
*
* @legacy-covers ::prepare
*/
public function testNoBaseTable() : void {
$this->expectException(QueryException::class);
$this->expectExceptionMessage('No base table for example_entity_query, invalid query.');
$this->query
->execute();
}
/**
* Tests revision entity query for entity type without revision table.
*
* @legacy-covers ::prepare
*/
public function testNoRevisionTable() : void {
$this->expectException(QueryException::class);
$this->expectExceptionMessage('No revision table for example_entity_query, invalid query.');
$this->query
->allRevisions()
->execute();
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
| ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
| ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
| QueryTest::$query | protected | property | The query object. | |
| QueryTest::setUp | protected | function | Overrides UnitTestCase::setUp | |
| QueryTest::testNoBaseTable | public | function | Tests entity query for entity type without base table. | |
| QueryTest::testNoRevisionTable | public | function | Tests revision entity query for entity type without revision table. | |
| RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |
| RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |
| RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |
| RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |
| UnitTestCase::$root | protected | property | The app root. | |
| UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |
| UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |
| UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |
| UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |
| UnitTestCase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |
| UnitTestCase::setupMockIterator | protected | function | Set up a traversable class mock to return specific items when iterated. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.