You are here

class QueryTest in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/views_ui/src/Tests/QueryTest.php \Drupal\views_ui\Tests\QueryTest
  2. 8 core/modules/views/src/Tests/Plugin/QueryTest.php \Drupal\views\Tests\Plugin\QueryTest
  3. 8 core/modules/system/src/Tests/Database/QueryTest.php \Drupal\system\Tests\Database\QueryTest
  4. 8 core/tests/Drupal/Tests/Core/Entity/Query/Sql/QueryTest.php \Drupal\Tests\Core\Entity\Query\Sql\QueryTest
  5. 8 core/modules/views/tests/modules/views_test_data/src/Plugin/views/query/QueryTest.php \Drupal\views_test_data\Plugin\views\query\QueryTest
Same name and namespace in other branches
  1. 8.0 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 extends \Drupal\Tests\PHPUnit_Framework_TestCase
    • class \Drupal\Tests\Core\Entity\Query\Sql\QueryTest

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 18
Contains \Drupal\Tests\Core\Entity\Query\Sql\QueryTest.

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() {
    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
   *
   * @expectedException \Drupal\Core\Entity\Query\QueryException
   * @expectedExceptionMessage No base table for example_entity_query, invalid query.
   */
  public function testNoBaseTable() {
    $this->query
      ->execute();
  }

  /**
   * Tests revision entity query for entity type without revision table.
   *
   * @covers ::prepare
   *
   * @expectedException \Drupal\Core\Entity\Query\QueryException
   * @expectedExceptionMessage No revision table for example_entity_query, invalid query.
   */
  public function testNoRevisionTable() {
    $this->query
      ->allRevisions()
      ->execute();
  }

}

Members

Namesort descending Modifiers Type Description 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.
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName protected function Mocks a block with a block plugin.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in 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.