Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Entity / Query / Sql / QueryTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Entity\Query\Sql;
4
5 use Drupal\Core\Entity\EntityType;
6 use Drupal\Tests\UnitTestCase;
7 use Drupal\Core\Entity\Query\QueryException;
8 use Drupal\Core\Entity\Query\Sql\Query;
9
10 /**
11  * @coversDefaultClass \Drupal\Core\Entity\Query\Sql\Query
12  * @group Entity
13  */
14 class QueryTest extends UnitTestCase {
15
16   /**
17    * The query object.
18    *
19    * @var \Drupal\Core\Entity\Query\Sql\Query
20    */
21   protected $query;
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function setUp() {
27     parent::setUp();
28     $entity_type = new EntityType(['id' => 'example_entity_query']);
29     $conjunction = 'AND';
30     $connection = $this->getMockBuilder('Drupal\Core\Database\Connection')->disableOriginalConstructor()->getMock();
31     $namespaces = ['Drupal\Core\Entity\Query\Sql'];
32
33     $this->query = new Query($entity_type, $conjunction, $connection, $namespaces);
34   }
35
36   /**
37    * Tests entity query for entity type without base table.
38    *
39    * @covers ::prepare
40    */
41   public function testNoBaseTable() {
42     $this->setExpectedException(QueryException::class, 'No base table for example_entity_query, invalid query.');
43     $this->query->execute();
44   }
45
46   /**
47    * Tests revision entity query for entity type without revision table.
48    *
49    * @covers ::prepare
50    */
51   public function testNoRevisionTable() {
52     $this->setExpectedException(QueryException::class, 'No revision table for example_entity_query, invalid query.');
53     $this->query->allRevisions()->execute();
54   }
55
56 }