Loading modules/redirect_404/tests/src/Functional/Fix404RedirectUILanguageTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -95,8 +95,8 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { 'source' => 'testing', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'testing'); $this->assertOptionSelected('edit-language-0-value', 'fr'); // Save the redirect. Loading Loading @@ -184,8 +184,8 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { 'source' => 'testing1', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'testing1'); $this->assertOptionSelected('edit-language-0-value', 'en'); $edit = ['redirect_redirect[0][uri]' => '/node']; Loading modules/redirect_404/tests/src/Functional/Fix404RedirectUITest.php +4 −4 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ class Fix404RedirectUITest extends Redirect404TestBase { 'source' => 'non-existing0', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'non-existing0'); // Save the redirect. $edit = ['redirect_redirect[0][uri]' => '/node']; Loading Loading @@ -104,8 +104,8 @@ class Fix404RedirectUITest extends Redirect404TestBase { 'destination' => $destination, ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'non-existing2'); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertUrl('admin/config/search/redirect/404'); Loading modules/redirect_404/tests/src/Functional/Redirect404LogSuppressorTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ class Redirect404LogSuppressorTest extends Redirect404TestBase { $this->assertResponse(403); // Assert the events are logged in the dblog reports. $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField(), 1); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField(), 1); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField()); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField()); // Login as admin and enable suppress_404 to avoid logging the 404 event. $this->drupalLogin($this->adminUser); Loading @@ -75,8 +75,8 @@ class Redirect404LogSuppressorTest extends Redirect404TestBase { // Assert only the new access denied event is logged now. $this->drupalLogin($this->adminUser); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField(), 1); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField(), 2); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField()); $this->assertEquals(2, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField()); } } tests/src/Functional/AssertRedirectTrait.php +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ trait AssertRedirectTrait { $expected_ending_url = NULL; } $this->assertEqual($expected_ending_url, $ending_url, $message); $this->assertEquals($ending_url, $expected_ending_url, $message); return $response; } Loading tests/src/Functional/RedirectUITest.php +7 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class RedirectUITest extends BrowserTestBase { $this->drupalPostForm('node/' . $node->id() . '/edit', ['path[0][alias]' => '/node_test_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('node_test_alias', [], Language::LANGCODE_NOT_SPECIFIED); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:node_test_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:node_test_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('node_test_alias', 'node_test_alias_updated'); Loading @@ -102,7 +102,7 @@ class RedirectUITest extends BrowserTestBase { $this->assertLinkByHref(Url::fromRoute('entity.redirect.edit_form', ['redirect' => $redirect->id()])->toString()); $this->assertLinkByHref(Url::fromRoute('entity.redirect.delete_form', ['redirect' => $redirect->id()])->toString()); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:node_test_alias')->toString()); $this->assertEquals(Url::fromUri('base:node_test_alias')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('node_test_alias_updated', 'node_test_alias'); Loading @@ -116,7 +116,7 @@ class RedirectUITest extends BrowserTestBase { $term = $this->createTerm($this->createVocabulary()); $this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', ['path[0][alias]' => '/term_test_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('term_test_alias'); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:term_test_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:term_test_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('term_test_alias', 'term_test_alias_updated'); Loading @@ -140,7 +140,7 @@ class RedirectUITest extends BrowserTestBase { $this->clickLink(t('Edit')); $this->drupalPostForm(NULL, [$alias_field => '/aaa_path_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('aaa_path_alias', [], 'en'); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:aaa_path_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:aaa_path_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('aaa_path_alias', 'aaa_path_alias_updated'); Loading Loading @@ -242,14 +242,14 @@ class RedirectUITest extends BrowserTestBase { // Note, self::assertCacheTag() cannot be used here since it only looks at // the final set of headers. $expected = 'http_response ' . implode(' ', $redirect1->getCacheTags()); $this->assertEqual($expected, $response->getHeader('x-drupal-cache-tags')[0], 'Redirect cache tags properly set.'); $this->assertEquals($expected, $response->getHeader('x-drupal-cache-tags')[0], 'Redirect cache tags properly set.'); // First request should be a cache MISS. $this->assertEqual($response->getHeader('x-drupal-cache')[0], 'MISS', 'First request to the redirect was not cached.'); $this->assertEquals('MISS', $response->getHeader('x-drupal-cache')[0], 'First request to the redirect was not cached.'); // Second request should be cached. $response = $this->assertRedirect('test-redirect', 'node'); $this->assertEqual($response->getHeader('x-drupal-cache')[0], 'HIT', 'The second request to the redirect was cached.'); $this->assertEquals('HIT', $response->getHeader('x-drupal-cache')[0], 'The second request to the redirect was cached.'); // Ensure that the redirect has been cleared from cache when deleted. $redirect1->delete(); Loading Loading
modules/redirect_404/tests/src/Functional/Fix404RedirectUILanguageTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -95,8 +95,8 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { 'source' => 'testing', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'testing'); $this->assertOptionSelected('edit-language-0-value', 'fr'); // Save the redirect. Loading Loading @@ -184,8 +184,8 @@ class Fix404RedirectUILanguageTest extends Redirect404TestBase { 'source' => 'testing1', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'testing1'); $this->assertOptionSelected('edit-language-0-value', 'en'); $edit = ['redirect_redirect[0][uri]' => '/node']; Loading
modules/redirect_404/tests/src/Functional/Fix404RedirectUITest.php +4 −4 Original line number Diff line number Diff line Loading @@ -33,8 +33,8 @@ class Fix404RedirectUITest extends Redirect404TestBase { 'source' => 'non-existing0', ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'non-existing0'); // Save the redirect. $edit = ['redirect_redirect[0][uri]' => '/node']; Loading Loading @@ -104,8 +104,8 @@ class Fix404RedirectUITest extends Redirect404TestBase { 'destination' => $destination, ]; $parsed_url = UrlHelper::parse($this->getUrl()); $this->assertEqual(Url::fromRoute('redirect.add')->setAbsolute()->toString(), $parsed_url['path']); $this->assertEqual($expected_query, $parsed_url['query']); $this->assertEquals($parsed_url['path'], Url::fromRoute('redirect.add')->setAbsolute()->toString()); $this->assertEquals($parsed_url['query'], $expected_query); $this->assertFieldByName('redirect_source[0][path]', 'non-existing2'); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertUrl('admin/config/search/redirect/404'); Loading
modules/redirect_404/tests/src/Functional/Redirect404LogSuppressorTest.php +4 −4 Original line number Diff line number Diff line Loading @@ -58,8 +58,8 @@ class Redirect404LogSuppressorTest extends Redirect404TestBase { $this->assertResponse(403); // Assert the events are logged in the dblog reports. $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField(), 1); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField(), 1); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField()); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField()); // Login as admin and enable suppress_404 to avoid logging the 404 event. $this->drupalLogin($this->adminUser); Loading @@ -75,8 +75,8 @@ class Redirect404LogSuppressorTest extends Redirect404TestBase { // Assert only the new access denied event is logged now. $this->drupalLogin($this->adminUser); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField(), 1); $this->assertEqual(Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField(), 2); $this->assertEquals(1, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'page not found'")->fetchField()); $this->assertEquals(2, Database::getConnection()->query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'access denied'")->fetchField()); } }
tests/src/Functional/AssertRedirectTrait.php +1 −1 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ trait AssertRedirectTrait { $expected_ending_url = NULL; } $this->assertEqual($expected_ending_url, $ending_url, $message); $this->assertEquals($ending_url, $expected_ending_url, $message); return $response; } Loading
tests/src/Functional/RedirectUITest.php +7 −7 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class RedirectUITest extends BrowserTestBase { $this->drupalPostForm('node/' . $node->id() . '/edit', ['path[0][alias]' => '/node_test_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('node_test_alias', [], Language::LANGCODE_NOT_SPECIFIED); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:node_test_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:node_test_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('node_test_alias', 'node_test_alias_updated'); Loading @@ -102,7 +102,7 @@ class RedirectUITest extends BrowserTestBase { $this->assertLinkByHref(Url::fromRoute('entity.redirect.edit_form', ['redirect' => $redirect->id()])->toString()); $this->assertLinkByHref(Url::fromRoute('entity.redirect.delete_form', ['redirect' => $redirect->id()])->toString()); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:node_test_alias')->toString()); $this->assertEquals(Url::fromUri('base:node_test_alias')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('node_test_alias_updated', 'node_test_alias'); Loading @@ -116,7 +116,7 @@ class RedirectUITest extends BrowserTestBase { $term = $this->createTerm($this->createVocabulary()); $this->drupalPostForm('taxonomy/term/' . $term->id() . '/edit', ['path[0][alias]' => '/term_test_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('term_test_alias'); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:term_test_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:term_test_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('term_test_alias', 'term_test_alias_updated'); Loading @@ -140,7 +140,7 @@ class RedirectUITest extends BrowserTestBase { $this->clickLink(t('Edit')); $this->drupalPostForm(NULL, [$alias_field => '/aaa_path_alias_updated'], t('Save')); $redirect = $this->repository->findMatchingRedirect('aaa_path_alias', [], 'en'); $this->assertEqual($redirect->getRedirectUrl()->toString(), Url::fromUri('base:aaa_path_alias_updated')->toString()); $this->assertEquals(Url::fromUri('base:aaa_path_alias_updated')->toString(), $redirect->getRedirectUrl()->toString()); // Test if the automatically created redirect works. $this->assertRedirect('aaa_path_alias', 'aaa_path_alias_updated'); Loading Loading @@ -242,14 +242,14 @@ class RedirectUITest extends BrowserTestBase { // Note, self::assertCacheTag() cannot be used here since it only looks at // the final set of headers. $expected = 'http_response ' . implode(' ', $redirect1->getCacheTags()); $this->assertEqual($expected, $response->getHeader('x-drupal-cache-tags')[0], 'Redirect cache tags properly set.'); $this->assertEquals($expected, $response->getHeader('x-drupal-cache-tags')[0], 'Redirect cache tags properly set.'); // First request should be a cache MISS. $this->assertEqual($response->getHeader('x-drupal-cache')[0], 'MISS', 'First request to the redirect was not cached.'); $this->assertEquals('MISS', $response->getHeader('x-drupal-cache')[0], 'First request to the redirect was not cached.'); // Second request should be cached. $response = $this->assertRedirect('test-redirect', 'node'); $this->assertEqual($response->getHeader('x-drupal-cache')[0], 'HIT', 'The second request to the redirect was cached.'); $this->assertEquals('HIT', $response->getHeader('x-drupal-cache')[0], 'The second request to the redirect was cached.'); // Ensure that the redirect has been cleared from cache when deleted. $redirect1->delete(); Loading