public function AdminUITest::doFlagReset in Flag 8.4
Reset the flag and ensure the flaggings are deleted.
1 call to AdminUITest::doFlagReset()
- AdminUITest::testFlagAdmin in tests/
src/ Functional/ AdminUITest.php - Test basic flag admin.
File
- tests/
src/ Functional/ AdminUITest.php, line 176
Class
- AdminUITest
- Tests the Flag admin UI.
Namespace
Drupal\Tests\flag\FunctionalCode
public function doFlagReset() {
// Flag the node.
$this->flagService
->flag($this->flag, $this->node, $this->adminUser);
$query_before = $this->entityTypeManager
->getStorage('flagging')
->getQuery();
$query_before
->condition('flag_id', $this->flag
->id())
->condition('entity_type', 'node')
->condition('entity_id', $this->node
->id());
$ids_before = $query_before
->execute();
$this
->assertEqual(count($ids_before), 1, "The flag has one flagging.");
// Go to the reset form for the flag.
$this
->drupalGet('admin/structure/flags/manage/' . $this->flag
->id() . '/reset');
$this
->assertText($this
->t('Are you sure you want to reset the Flag'));
$this
->drupalPostForm(NULL, [], $this
->t('Reset'));
$query_after = $this->entityTypeManager
->getStorage('flagging')
->getQuery();
$query_after
->condition('flag_id', $this->flag
->id())
->condition('entity_type', 'node')
->condition('entity_id', $this->node
->id());
$ids_after = $query_after
->execute();
$this
->assertEqual(count($ids_after), 0, "The flag has no flaggings after being reset.");
}