Loading modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php→modules/redirect_404/tests/src/Functional/Fix404RedirectUILanguageTest.php +5 −5 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\redirect\Tests\AssertRedirectTrait; use Drupal\Tests\redirect\Functional\AssertRedirectTrait; /** * UI tests for redirect_404 module with language and content translation. Loading Loading @@ -105,7 +105,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->assertUrl('admin/config/search/redirect/404'); $this->assertText('There are no 404 errors to fix.'); // Check if the redirect works as expected. $this->assertRedirect('fr/testing', 'fr/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('fr/testing', 'fr/node', 301); // Test removing a redirect assignment, visit again the non existing page. $this->drupalGet('admin/config/search/redirect'); Loading Loading @@ -136,7 +136,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->drupalGet('admin/config/search/redirect'); $this->assertLanguageInTableBody('Spanish'); // Check if the redirect works as expected. $this->assertRedirect('es/testing', 'es/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('es/testing', 'es/node', 301); // Visit multiple non existing pages to test the Redirect 404 View. $this->drupalGet('testing1'); Loading Loading @@ -197,7 +197,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->assertLanguageInTableBody('Spanish'); $this->assertLanguageInTableBody('English'); // Check if the redirect works as expected. $this->assertRedirect('/testing1', '/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('/testing1', '/node', 301); } } modules/redirect_404/src/Tests/Fix404RedirectUITest.php→modules/redirect_404/tests/src/Functional/Fix404RedirectUITest.php +9 −10 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Url; Loading Loading @@ -158,10 +158,9 @@ class Fix404RedirectUITest extends Redirect404TestBase { $this->clickLink('Ignore'); $this->assertUrl('admin/config/search/redirect/settings?ignore=' . $path_to_ignore . $destination); $this->assertText('Resolved the path ' . $path_to_ignore . ' in the database. Please check the ignored list and save the settings.'); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->asXML(); $this->assertTrue(strpos($xpath, $node_to_ignore), $node_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $terms_to_ignore), $terms_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $path_to_ignore), $path_to_ignore . " in 'Path to ignore' found"); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $node_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $terms_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $path_to_ignore); // Save the path with wildcard, but omitting the leading slash. $nodes_to_ignore = 'node/*'; Loading @@ -175,12 +174,12 @@ class Fix404RedirectUITest extends Redirect404TestBase { // Go back to the settings to check the 'Path to ignore' configurations. $this->drupalGet('admin/config/search/redirect/settings'); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->asXML(); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->getHtml(); // Check that the new page to ignore has been saved with leading slash. $this->assertTrue(strpos($xpath, '/' . $nodes_to_ignore), '/' . $nodes_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $terms_to_ignore), $terms_to_ignore . " in 'Path to ignore' found"); $this->assertFalse(strpos($xpath, $node_to_ignore), $node_to_ignore . " in 'Path to ignore' found"); $this->assertFalse(strpos($xpath, $path_to_ignore), $path_to_ignore . " in 'Path to ignore' found"); $this->assertSession()->elementContains('css', '#edit-ignore-pages', '/'. $nodes_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $terms_to_ignore); $this->assertSession()->elementNotContains('css', '#edit-ignore-pages', $node_to_ignore); $this->assertSession()->elementNotContains('css', '#edit-ignore-pages', $path_to_ignore); } } modules/redirect_404/src/Tests/Redirect404LogSuppressorTest.php→modules/redirect_404/tests/src/Functional/Redirect404LogSuppressorTest.php +1 −1 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; /** * Tests suppressing 404 logs if the suppress_404 setting is enabled. Loading modules/redirect_404/src/Tests/Redirect404TestBase.php→modules/redirect_404/tests/src/Functional/Redirect404TestBase.php +84 −0 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Render\FormattableMarkup; use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase; /** * This class provides methods specifically for testing redirect 404 paths. */ abstract class Redirect404TestBase extends WebTestBase { abstract class Redirect404TestBase extends BrowserTestBase { /** * Modules to enable. Loading Loading @@ -63,20 +63,9 @@ abstract class Redirect404TestBase extends WebTestBase { * * @param string $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertLanguageInTableBody($language, $body = '//table/tbody', $message = '') { return $this->assertLanguageInTableBodyHelper($language, $body, $message, FALSE); protected function assertLanguageInTableBody($language) { $this->assertSession()->elementContains('css', 'table tbody', $language); } /** Loading @@ -87,58 +76,9 @@ abstract class Redirect404TestBase extends WebTestBase { * * @param string $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertNoLanguageInTableBody($language, $body = '//table/tbody', $message = '') { return $this->assertLanguageInTableBodyHelper($language, $body, $message, TRUE); } /** * Helper for assertLanguageInTableBody and assertNoLanguageInTableBody. * * @param array $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * @param bool $not_exists * (optional) TRUE if this language should not exist, FALSE if it should. * Defaults to TRUE. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertLanguageInTableBodyHelper($language, $body = '//table/tbody', $message = '', $not_exists = TRUE) { if (!$message) { if (!$not_exists) { $message = new FormattableMarkup('Language "@language" found in 404 table.', ['@language' => $language]); } else { $message = new FormattableMarkup('Language "@language" not found in 404 table.', ['@language' => $language]); } } if ($not_exists) { return $this->assertFalse(strpos($this->xpath($body)[0]->asXML(), $language), $message); } else { return $this->assertTrue(strpos($this->xpath($body)[0]->asXML(), $language), $message); } protected function assertNoLanguageInTableBody($language) { $this->assertSession()->elementNotContains('css', 'table tbody', $language); } } modules/redirect_domain/src/Tests/RedirectDomainUITest.php→modules/redirect_domain/tests/src/FunctionalJavascript/RedirectDomainUITest.php +13 −13 Original line number Diff line number Diff line <?php namespace Drupal\redirect_domain\Tests; namespace Drupal\Tests\redirect_domain\FunctionalJavascript; use Drupal\simpletest\WebTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the UI for domain redirect. * * @group redirect_domain */ class RedirectDomainUITest extends WebTestBase { class RedirectDomainUITest extends WebDriverTestBase { /** * Modules to enable. Loading Loading @@ -38,18 +38,18 @@ class RedirectDomainUITest extends WebTestBase { $this->assertFieldByName('redirects[0][destination]'); // Add another field for new domain redirect. $this->drupalPostAjaxForm(NULL, [], ['op' => t('Add another')]); $page = $this->getSession()->getPage(); $page->pressButton('Add another'); $this->assertSession()->assertWaitOnAjaxRequest(); // Add two new domain redirects. $edit = [ 'redirects[0][from]' => 'foo.example.org', 'redirects[0][sub_path]' => '//sub-path', 'redirects[0][destination]' => 'www.example.org/foo', 'redirects[1][from]' => 'bar.example.org', 'redirects[1][sub_path]' => '', 'redirects[1][destination]' => 'www.example.org/bar', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $page->fillField('redirects[0][from]', 'foo.example.org'); $page->fillField('redirects[0][sub_path]', '//sub-path'); $page->fillField('redirects[0][destination]', 'www.example.org/foo'); $page->fillField('redirects[1][from]', 'bar.example.org'); $page->fillField('redirects[1][sub_path]', ''); $page->fillField('redirects[1][destination]', 'www.example.org/bar'); $page->pressButton('Save'); // Check the new domain redirects. $this->assertFieldByName('redirects[0][from]', 'foo.example.org'); Loading Loading
modules/redirect_404/src/Tests/Fix404RedirectUILanguageTest.php→modules/redirect_404/tests/src/Functional/Fix404RedirectUILanguageTest.php +5 −5 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Url; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\redirect\Tests\AssertRedirectTrait; use Drupal\Tests\redirect\Functional\AssertRedirectTrait; /** * UI tests for redirect_404 module with language and content translation. Loading Loading @@ -105,7 +105,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->assertUrl('admin/config/search/redirect/404'); $this->assertText('There are no 404 errors to fix.'); // Check if the redirect works as expected. $this->assertRedirect('fr/testing', 'fr/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('fr/testing', 'fr/node', 301); // Test removing a redirect assignment, visit again the non existing page. $this->drupalGet('admin/config/search/redirect'); Loading Loading @@ -136,7 +136,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->drupalGet('admin/config/search/redirect'); $this->assertLanguageInTableBody('Spanish'); // Check if the redirect works as expected. $this->assertRedirect('es/testing', 'es/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('es/testing', 'es/node', 301); // Visit multiple non existing pages to test the Redirect 404 View. $this->drupalGet('testing1'); Loading Loading @@ -197,7 +197,7 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { $this->assertLanguageInTableBody('Spanish'); $this->assertLanguageInTableBody('English'); // Check if the redirect works as expected. $this->assertRedirect('/testing1', '/node', 'HTTP/1.1 301 Moved Permanently'); $this->assertRedirect('/testing1', '/node', 301); } }
modules/redirect_404/src/Tests/Fix404RedirectUITest.php→modules/redirect_404/tests/src/Functional/Fix404RedirectUITest.php +9 −10 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Url; Loading Loading @@ -158,10 +158,9 @@ class Fix404RedirectUITest extends Redirect404TestBase { $this->clickLink('Ignore'); $this->assertUrl('admin/config/search/redirect/settings?ignore=' . $path_to_ignore . $destination); $this->assertText('Resolved the path ' . $path_to_ignore . ' in the database. Please check the ignored list and save the settings.'); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->asXML(); $this->assertTrue(strpos($xpath, $node_to_ignore), $node_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $terms_to_ignore), $terms_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $path_to_ignore), $path_to_ignore . " in 'Path to ignore' found"); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $node_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $terms_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $path_to_ignore); // Save the path with wildcard, but omitting the leading slash. $nodes_to_ignore = 'node/*'; Loading @@ -175,12 +174,12 @@ class Fix404RedirectUITest extends Redirect404TestBase { // Go back to the settings to check the 'Path to ignore' configurations. $this->drupalGet('admin/config/search/redirect/settings'); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->asXML(); $xpath = $this->xpath('//*[@id="edit-ignore-pages"]')[0]->getHtml(); // Check that the new page to ignore has been saved with leading slash. $this->assertTrue(strpos($xpath, '/' . $nodes_to_ignore), '/' . $nodes_to_ignore . " in 'Path to ignore' found"); $this->assertTrue(strpos($xpath, $terms_to_ignore), $terms_to_ignore . " in 'Path to ignore' found"); $this->assertFalse(strpos($xpath, $node_to_ignore), $node_to_ignore . " in 'Path to ignore' found"); $this->assertFalse(strpos($xpath, $path_to_ignore), $path_to_ignore . " in 'Path to ignore' found"); $this->assertSession()->elementContains('css', '#edit-ignore-pages', '/'. $nodes_to_ignore); $this->assertSession()->elementContains('css', '#edit-ignore-pages', $terms_to_ignore); $this->assertSession()->elementNotContains('css', '#edit-ignore-pages', $node_to_ignore); $this->assertSession()->elementNotContains('css', '#edit-ignore-pages', $path_to_ignore); } }
modules/redirect_404/src/Tests/Redirect404LogSuppressorTest.php→modules/redirect_404/tests/src/Functional/Redirect404LogSuppressorTest.php +1 −1 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; /** * Tests suppressing 404 logs if the suppress_404 setting is enabled. Loading
modules/redirect_404/src/Tests/Redirect404TestBase.php→modules/redirect_404/tests/src/Functional/Redirect404TestBase.php +84 −0 Original line number Diff line number Diff line <?php namespace Drupal\redirect_404\Tests; namespace Drupal\Tests\redirect_404\Functional; use Drupal\Component\Render\FormattableMarkup; use Drupal\simpletest\WebTestBase; use Drupal\Tests\BrowserTestBase; /** * This class provides methods specifically for testing redirect 404 paths. */ abstract class Redirect404TestBase extends WebTestBase { abstract class Redirect404TestBase extends BrowserTestBase { /** * Modules to enable. Loading Loading @@ -63,20 +63,9 @@ abstract class Redirect404TestBase extends WebTestBase { * * @param string $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertLanguageInTableBody($language, $body = '//table/tbody', $message = '') { return $this->assertLanguageInTableBodyHelper($language, $body, $message, FALSE); protected function assertLanguageInTableBody($language) { $this->assertSession()->elementContains('css', 'table tbody', $language); } /** Loading @@ -87,58 +76,9 @@ abstract class Redirect404TestBase extends WebTestBase { * * @param string $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertNoLanguageInTableBody($language, $body = '//table/tbody', $message = '') { return $this->assertLanguageInTableBodyHelper($language, $body, $message, TRUE); } /** * Helper for assertLanguageInTableBody and assertNoLanguageInTableBody. * * @param array $language * The language to assert in the redirect 404 table body. * @param string $body * (optional) The table body xpath where to assert the language. Defaults * to '//table/tbody'. * @param string $message * (optional) A message to display with the assertion. Do not translate * messages: use \Drupal\Component\Utility\SafeMarkup::format() to embed * variables in the message text, not t(). If left blank, a default message * will be displayed. * @param bool $not_exists * (optional) TRUE if this language should not exist, FALSE if it should. * Defaults to TRUE. * * @return bool * TRUE on pass, FALSE on fail. */ protected function assertLanguageInTableBodyHelper($language, $body = '//table/tbody', $message = '', $not_exists = TRUE) { if (!$message) { if (!$not_exists) { $message = new FormattableMarkup('Language "@language" found in 404 table.', ['@language' => $language]); } else { $message = new FormattableMarkup('Language "@language" not found in 404 table.', ['@language' => $language]); } } if ($not_exists) { return $this->assertFalse(strpos($this->xpath($body)[0]->asXML(), $language), $message); } else { return $this->assertTrue(strpos($this->xpath($body)[0]->asXML(), $language), $message); } protected function assertNoLanguageInTableBody($language) { $this->assertSession()->elementNotContains('css', 'table tbody', $language); } }
modules/redirect_domain/src/Tests/RedirectDomainUITest.php→modules/redirect_domain/tests/src/FunctionalJavascript/RedirectDomainUITest.php +13 −13 Original line number Diff line number Diff line <?php namespace Drupal\redirect_domain\Tests; namespace Drupal\Tests\redirect_domain\FunctionalJavascript; use Drupal\simpletest\WebTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the UI for domain redirect. * * @group redirect_domain */ class RedirectDomainUITest extends WebTestBase { class RedirectDomainUITest extends WebDriverTestBase { /** * Modules to enable. Loading Loading @@ -38,18 +38,18 @@ class RedirectDomainUITest extends WebTestBase { $this->assertFieldByName('redirects[0][destination]'); // Add another field for new domain redirect. $this->drupalPostAjaxForm(NULL, [], ['op' => t('Add another')]); $page = $this->getSession()->getPage(); $page->pressButton('Add another'); $this->assertSession()->assertWaitOnAjaxRequest(); // Add two new domain redirects. $edit = [ 'redirects[0][from]' => 'foo.example.org', 'redirects[0][sub_path]' => '//sub-path', 'redirects[0][destination]' => 'www.example.org/foo', 'redirects[1][from]' => 'bar.example.org', 'redirects[1][sub_path]' => '', 'redirects[1][destination]' => 'www.example.org/bar', ]; $this->drupalPostForm(NULL, $edit, t('Save')); $page->fillField('redirects[0][from]', 'foo.example.org'); $page->fillField('redirects[0][sub_path]', '//sub-path'); $page->fillField('redirects[0][destination]', 'www.example.org/foo'); $page->fillField('redirects[1][from]', 'bar.example.org'); $page->fillField('redirects[1][sub_path]', ''); $page->fillField('redirects[1][destination]', 'www.example.org/bar'); $page->pressButton('Save'); // Check the new domain redirects. $this->assertFieldByName('redirects[0][from]', 'foo.example.org'); Loading