public function MatcherAdminTest::testDelete in Linkit 8.5
Test delete a matcher from a profile.
File
- tests/
src/ Functional/ MatcherAdminTest.php, line 103
Class
- MatcherAdminTest
- Tests adding, listing, updating and deleting matchers on a profile.
Namespace
Drupal\Tests\linkit\FunctionalCode
public function testDelete() {
$this
->drupalLogin($this->adminUser);
/** @var \Drupal\linkit\MatcherInterface $plugin */
$plugin = $this->manager
->createInstance('dummy_matcher');
$plugin_uuid = $this->linkitProfile
->addMatcher($plugin
->getConfiguration());
$this->linkitProfile
->save();
// Try delete a matcher that is not attached to the profile.
$this
->drupalGet('/admin/config/content/linkit/manage/' . $this->linkitProfile
->id() . '/matchers/doesntexists/delete');
$this
->assertSession()
->statusCodeEquals('404');
// Go to the delete page, but press cancel.
$this
->drupalGet('/admin/config/content/linkit/manage/' . $this->linkitProfile
->id() . '/matchers/' . $plugin_uuid . '/delete');
$this
->clickLink($this
->t('Cancel'));
$this
->assertSession()
->addressEquals('/admin/config/content/linkit/manage/' . $this->linkitProfile
->id() . '/matchers');
// Delete the matcher from the profile.
$this
->drupalGet('/admin/config/content/linkit/manage/' . $this->linkitProfile
->id() . '/matchers/' . $plugin_uuid . '/delete');
$this
->submitForm([], $this
->t('Confirm'));
$this
->assertSession()
->pageTextContains('The matcher Dummy Matcher has been deleted.');
$this
->assertSession()
->addressEquals('/admin/config/content/linkit/manage/' . $this->linkitProfile
->id() . '/matchers');
$this
->assertSession()
->pageTextContains('No matchers added.');
/** @var \Drupal\linkit\Entity\Profile $updated_profile */
$updated_profile = Profile::load($this->linkitProfile
->id());
$this
->assertFalse($updated_profile
->getMatchers()
->has($plugin_uuid), 'The user matcher is deleted from the profile');
}