class QueryTest

Same name in this branch
  1. 9 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  2. 9 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest
Same name and namespace in other branches
  1. 8.9.x core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest
  3. 8.9.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest
  4. 10 core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  5. 10 core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest
  6. 10 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest
  7. 11.x core/modules/views_ui/tests/src/Functional/QueryTest.php \Drupal\Tests\views_ui\Functional\QueryTest
  8. 11.x core/tests/Drupal/KernelTests/Core/Database/QueryTest.php \Drupal\KernelTests\Core\Database\QueryTest
  9. 11.x core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest

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

Hierarchy

  • class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase

Expanded class hierarchy of QueryTest

File

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

Namespace

Drupal\Tests\Core\Entity\Query\Sql
View 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);
  }
  
  /**
   * Tests entity query for entity type without base table.
   *
   * @covers ::prepare
   */
  public function testNoBaseTable() {
    $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.
   *
   * @covers ::prepare
   */
  public function testNoRevisionTable() {
    $this->expectException(QueryException::class);
    $this->expectExceptionMessage('No revision table for example_entity_query, invalid query.');
    $this->query
      ->allRevisions()
      ->execute();
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
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.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals Deprecated protected function Asserts if two arrays are equal by sorting them first.
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::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.
UnitTestCase::setUpBeforeClass public static function

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