Skip to content
Snippets Groups Projects
Commit dd90589f authored by Ivan Doroshenko's avatar Ivan Doroshenko
Browse files

Issue #3303716: Settings page - added test coverage for bundles statuses.

parent fb5f265d
Branches
Tags
1 merge request!68Issue #3298741: Fix the issues reported by phpcs
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\rabbit_hole\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait;
/**
* Test the RabbitHoleSettingsForm form functionality.
......@@ -13,6 +14,8 @@ use Drupal\Tests\BrowserTestBase;
*/
class RabbitHoleSettingsFormTest extends BrowserTestBase {
use TaxonomyTestTrait;
/**
* {@inheritdoc}
*/
......@@ -36,25 +39,49 @@ class RabbitHoleSettingsFormTest extends BrowserTestBase {
$this->assertSession()->pageTextContains('There are no supported entity types yet. Please enable one of the submodules.');
$this->submitForm([], 'Save configuration');
\Drupal::service('module_installer')->install(['rh_user', 'rh_taxonomy']);
\Drupal::service('module_installer')->install(['rh_user', 'rh_node', 'rh_taxonomy']);
$this->drupalGet('admin/config/content/rabbit-hole');
$this->assertSession()->fieldExists('entity_types[user]');
$this->assertSession()->fieldExists('entity_types[node]');
$this->assertSession()->fieldExists('entity_types[taxonomy_term]');
// Make sure unsupported entity types are not available.
$this->assertSession()->fieldNotExists('entity_types[node]');
$this->assertSession()->fieldNotExists('entity_types[media]');
// Verify form submit.
$this->submitForm(['entity_types[user]' => TRUE], 'Save configuration');
$this->submitForm([
'entity_types[user]' => TRUE,
'entity_types[taxonomy_term]' => TRUE,
], 'Save configuration');
$this->assertSession()->checkboxChecked('entity_types[taxonomy_term]');
$this->assertSession()->checkboxChecked('entity_types[user]');
$this->assertSession()->checkboxNotChecked('entity_types[taxonomy_term]');
$this->assertSession()->checkboxNotChecked('entity_types[node]');
// Check operations.
$this->assertSession()->elementExists('css', 'tr[data-drupal-selector="edit-table-user"] a');
$this->assertSession()->elementNotExists('css', 'tr[data-drupal-selector="edit-table-taxonomy-term"] a');
$this->assertSession()->elementNotExists('css', 'tr[data-drupal-selector="edit-table-node"] a');
// Check entity type settings page.
$this->click('tr[data-drupal-selector="edit-table-user"] a');
$this->assertSession()->fieldExists('bundles[user][rh_action]');
$this->assertSession()->fieldExists('bundles[user][rh_override]');
// Add a couple pf taxonomy vocabularies.
$voc1 = $this->createVocabulary();
$voc2 = $this->createVocabulary();
// Make sure that default behavior is applied.
$this->drupalGet('admin/config/content/rabbit-hole');
$this->assertSession()->responseContains('<em class="placeholder">' . $voc1->label() . '</em> (Behavior: <em class="placeholder">Display the page</em>; Allow overrides: <em class="placeholder">Yes</em>)');
$this->assertSession()->responseContains('<em class="placeholder">' . $voc2->label() . '</em> (Behavior: <em class="placeholder">Display the page</em>; Allow overrides: <em class="placeholder">Yes</em>)');
$this->click('tr[data-drupal-selector="edit-table-taxonomy-term"] a');
$this->submitForm([
'bundles[' . $voc1->id() . '][rh_action]' => 'page_not_found',
'bundles[' . $voc1->id() . '][rh_override]' => FALSE,
], 'Save configuration');
$this->assertSession()->responseContains('<em class="placeholder">' . $voc1->label() . '</em> (Behavior: <em class="placeholder">Page not found</em>; Allow overrides: <em class="placeholder">No</em>)');
$this->assertSession()->responseContains('<em class="placeholder">' . $voc2->label() . '</em> (Behavior: <em class="placeholder">Display the page</em>; Allow overrides: <em class="placeholder">Yes</em>)');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment