diff --git a/modules/redirect_404/src/Plugin/views/field/Redirect404Operations.php b/modules/redirect_404/src/Plugin/views/field/Redirect404Operations.php index 4f31e877fe881dd90ab37694a9b4c4f0ab554b16..1ec3e5b292f1c121aa1586257fef1ed358d7c01a 100644 --- a/modules/redirect_404/src/Plugin/views/field/Redirect404Operations.php +++ b/modules/redirect_404/src/Plugin/views/field/Redirect404Operations.php @@ -33,6 +33,13 @@ class Redirect404Operations extends FieldPluginBase { */ protected $renderer; + /** + * The current user. + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + /** * Constructor for the redirect operations view field. * diff --git a/tests/src/Functional/RedirectUITest.php b/tests/src/Functional/RedirectUITest.php index fbac2500ba222ce6c6a16ab8b95d53dec5d96721..01fa5e44f0cab9169d022c8a9f604d62592023a8 100644 --- a/tests/src/Functional/RedirectUITest.php +++ b/tests/src/Functional/RedirectUITest.php @@ -19,24 +19,44 @@ class RedirectUITest extends BrowserTestBase { use AssertRedirectTrait; /** + * The admin user. + * * @var \Drupal\Core\Session\AccountInterface */ protected $adminUser; /** + * The redirect repository. + * * @var \Drupal\redirect\RedirectRepository */ protected $repository; /** + * The Sql conntent entity storage. + * * @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage */ - protected $storage; + protected $storage; + + /** + * The maximum redirects. + * + * @var int + */ + public $maximumRedirects; /** * {@inheritdoc} */ - protected static $modules = ['redirect', 'node', 'path', 'dblog', 'views', 'taxonomy']; + protected static $modules = [ + 'redirect', + 'node', + 'path', + 'dblog', + 'views', + 'taxonomy', + ]; /** * {@inheritdoc} @@ -156,7 +176,7 @@ class RedirectUITest extends BrowserTestBase { /** * Test the redirect loop protection and logging. */ - function testRedirectLoop() { + public function testRedirectLoop() { // Redirect loop redirection only works when page caching is disabled. \Drupal::service('module_installer')->uninstall(['page_cache']); @@ -194,7 +214,7 @@ class RedirectUITest extends BrowserTestBase { /** * Returns a new vocabulary with random properties. */ - function createVocabulary() { + public function createVocabulary() { // Create a vocabulary. $vocabulary = Vocabulary::create([ 'name' => $this->randomMachineName(), @@ -210,7 +230,7 @@ class RedirectUITest extends BrowserTestBase { /** * Returns a new term with random properties in vocabulary $vid. */ - function createTerm($vocabulary) { + public function createTerm($vocabulary) { $filter_formats = filter_formats(); $format = array_pop($filter_formats); $term = Term::create([ diff --git a/tests/src/FunctionalJavascript/RedirectJavascriptTest.php b/tests/src/FunctionalJavascript/RedirectJavascriptTest.php index 83ee44d67905944d12b98b2264ff50f552cc2d45..b3b7840239e8440dcba1bab622f419add387ede1 100644 --- a/tests/src/FunctionalJavascript/RedirectJavascriptTest.php +++ b/tests/src/FunctionalJavascript/RedirectJavascriptTest.php @@ -13,16 +13,22 @@ use Drupal\FunctionalJavascriptTests\WebDriverTestBase; class RedirectJavascriptTest extends WebDriverTestBase { /** + * The admin user. + * * @var \Drupal\Core\Session\AccountInterface */ protected $adminUser; /** + * The redirect repository. + * * @var \Drupal\redirect\RedirectRepository */ protected $repository; /** + * The Sql conntent entity storage. + * * @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage */ protected $storage; @@ -70,13 +76,13 @@ class RedirectJavascriptTest extends WebDriverTestBase { // Test populating the redirect form with predefined values. $this->drupalGet( 'admin/config/search/redirect/add', [ - 'query' => [ - 'source' => 'non-existing', - 'source_query' => ['key' => 'val', 'key1' => 'val1'], - 'redirect' => 'node', - 'redirect_options' => ['query' => ['key' => 'val', 'key1' => 'val1']], + 'query' => [ + 'source' => 'non-existing', + 'source_query' => ['key' => 'val', 'key1' => 'val1'], + 'redirect' => 'node', + 'redirect_options' => ['query' => ['key' => 'val', 'key1' => 'val1']], + ], ] - ] ); $this->assertSession()->fieldValueEquals('redirect_source[0][path]', 'non-existing?key=val&key1=val1'); $this->assertSession()->fieldValueEquals('redirect_redirect[0][uri]', '/node?key=val&key1=val1'); @@ -183,7 +189,7 @@ class RedirectJavascriptTest extends WebDriverTestBase { $page->pressButton('Save'); $this->assertSession()->responseContains('The anchor fragments are not allowed.'); - // Adding path that starts with / + // Adding path that starts with /. $this->drupalGet('admin/config/search/redirect/add'); $page = $this->getSession()->getPage(); $page->fillField('redirect_source[0][path]', '/page-to-redirect'); @@ -205,10 +211,10 @@ class RedirectJavascriptTest extends WebDriverTestBase { // Filter with non existing value. $this->drupalGet( 'admin/config/search/redirect', [ - 'query' => [ - 'status_code' => '3', - ], - ] + 'query' => [ + 'status_code' => '3', + ], + ] ); $rows = $this->xpath('//tbody/tr'); @@ -218,11 +224,11 @@ class RedirectJavascriptTest extends WebDriverTestBase { // Filter with existing values. $this->drupalGet( 'admin/config/search/redirect', [ - 'query' => [ - 'redirect_source__path' => 'test', - 'status_code' => '2', - ], - ] + 'query' => [ + 'redirect_source__path' => 'test', + 'status_code' => '2', + ], + ] ); $rows = $this->xpath('//tbody/tr'); @@ -231,10 +237,10 @@ class RedirectJavascriptTest extends WebDriverTestBase { $this->drupalGet( 'admin/config/search/redirect', [ - 'query' => [ - 'redirect_redirect__uri' => 'nod', - ], - ] + 'query' => [ + 'redirect_redirect__uri' => 'nod', + ], + ] ); $rows = $this->xpath('//tbody/tr'); @@ -247,6 +253,7 @@ class RedirectJavascriptTest extends WebDriverTestBase { 'redirect_bulk_form[0]' => TRUE, 'redirect_bulk_form[1]' => TRUE, ]; + $this->getSession()->getPage()->selectFieldOption("action", "redirect_delete_action", TRUE); $this->submitForm($edit, 'Apply to selected items'); $this->assertSession()->pageTextContains('Are you sure you want to delete these redirects?'); $this->clickLink('Cancel'); @@ -261,6 +268,7 @@ class RedirectJavascriptTest extends WebDriverTestBase { $this->assertSession()->addressEquals('admin/config/search/redirect'); // Test the bulk delete action. + $this->getSession()->getPage()->selectFieldOption("action", "redirect_delete_action", TRUE); $this->submitForm(['redirect_bulk_form[0]' => TRUE], 'Apply to selected items'); $this->assertSession()->pageTextContains('Are you sure you want to delete this redirect?'); $this->assertSession()->pageTextContains('test27');