function SqlTest::testGetCacheTags
Same name and namespace in other branches
- 9 core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testGetCacheTags()
- 8.9.x core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testGetCacheTags()
- 10 core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testGetCacheTags()
@covers ::getCacheTags @covers ::getAllEntities
File
-
core/
modules/ views/ tests/ src/ Unit/ Plugin/ query/ SqlTest.php, line 33
Class
- SqlTest
- @coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Plugin%21views%21query%21Sql.php/class/Sql/11.x" title="Views query plugin for an SQL query." class="local">\Drupal\views\Plugin\views\query\Sql</a>
Namespace
Drupal\Tests\views\Unit\Plugin\queryCode
public function testGetCacheTags() : void {
$view = $this->prophesize('Drupal\\views\\ViewExecutable')
->reveal();
$entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
$date_sql = $this->prophesize(DateSqlInterface::class);
$messenger = $this->prophesize(MessengerInterface::class);
$query = new Sql([], 'sql', [], $entity_type_manager->reveal(), $date_sql->reveal(), $messenger->reveal());
$query->view = $view;
$result = [];
$view->result = $result;
// Add a row with an entity.
$row = new ResultRow();
$prophecy = $this->prophesize('Drupal\\Core\\Entity\\EntityInterface');
$prophecy->getCacheTags()
->willReturn([
'entity_test:123',
]);
$entity = $prophecy->reveal();
$row->_entity = $entity;
$result[] = $row;
$view->result = $result;
// Add a row with an entity and a relationship entity.
$row = new ResultRow();
$prophecy = $this->prophesize('Drupal\\Core\\Entity\\EntityInterface');
$prophecy->getCacheTags()
->willReturn([
'entity_test:124',
]);
$entity = $prophecy->reveal();
$row->_entity = $entity;
$prophecy = $this->prophesize('Drupal\\Core\\Entity\\EntityInterface');
$prophecy->getCacheTags()
->willReturn([
'entity_test:125',
]);
$entity = $prophecy->reveal();
$row->_relationship_entities[] = $entity;
$prophecy = $this->prophesize('Drupal\\Core\\Entity\\EntityInterface');
$prophecy->getCacheTags()
->willReturn([
'entity_test:126',
]);
$entity = $prophecy->reveal();
$row->_relationship_entities[] = $entity;
$result[] = $row;
$view->result = $result;
$this->assertEqualsCanonicalizing([
'entity_test:123',
'entity_test:124',
'entity_test:125',
'entity_test:126',
], $query->getCacheTags());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.