public function NodeRevisionDeleteQueryAlterTest::testNodeRevisionDeleteQueryAlter in Node Revision Delete 8
Tests that appropriate tags are added when querying the database.
File
- tests/
src/ Kernel/ NodeRevisionDeleteQueryAlterTest.php, line 45
Class
- NodeRevisionDeleteQueryAlterTest
- Tests that appropriate query tags are added.
Namespace
Drupal\Tests\node_revision_delete\KernelCode
public function testNodeRevisionDeleteQueryAlter() {
// Add article node type.
$node_type = NodeType::create([
'type' => 'article',
'label' => 'Article',
]);
$node_type
->save();
$this->nodeRevisionDelete
->saveContentTypeConfig('article', 1, 0, 0);
// Add node and revisions.
$revision1 = Node::create([
'type' => 'article',
'title' => 'My article',
]);
$revision1
->save();
$revision2 = clone $revision1;
$revision2
->setNewRevision();
$revision2
->save();
$revision3 = clone $revision2;
$revision3
->setNewRevision();
$revision3
->save();
$this
->setupQueryTagTestHooks();
$this->nodeRevisionDelete
->getCandidatesNodes('article');
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidates_alter', 1);
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidates_article_alter', 1);
$this->nodeRevisionDelete
->getCandidatesRevisions('article');
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidate_revisions_alter', 1);
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidate_revisions_article_alter', 1);
$this->nodeRevisionDelete
->getCandidatesRevisionsByNids([
$revision1
->id(),
]);
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidate_revisions_alter', 2);
$this
->assertQueryTagTestResult('node_revision_delete_test_query_node_revision_delete_candidate_revisions_article_alter', 2);
}