Why is my functional test not matching my manual testing?

I have a Drupal 8 module for banning users based on country.

In it, I have the following test.

public function setUp() {   parent::setUp();   $this->drupalLogin($this->adminSitesUser); }  public function testCompleteBan() {   // node/1.   $this->addBanNode("Read only page");   // node/2.   $this->addBanNode("Complete ban page");   $this->drupalGet(IP_BAN_ADMIN_FORM_PATH);   $edit = [     // Set the United States to Read Only     // 0 = no action / 1 = Read Only / 2 = Complete Ban.     'ip_ban_US' => 2,     // Set the test IP address to a known Google US address.     'ip_ban_test_ip' => '66.249.84.22',     // Configure the paths for read-only and complete ban.     'ip_ban_readonly_path' => '/node/1',     'ip_ban_completeban_path' => '/node/2',   ];   $this->drupalPostForm(IP_BAN_ADMIN_FORM_PATH, $edit, t('Save configuration'));   $this->assertOptionSelected('edit-ip-ban-us', 2, 'Complete ban set correctly in country list table.');   // Should be redirected to complete ban page after logout.   $this->drupalGet('user/logout');   $this->assertUrl('node/2'); } 

However, I get an error on the last line (assertURL()): "Expected ‘http://d8.dev/node/2’ matches current URL (http://d8.dev/). Value ‘http://d8.dev/’ is equal to value ‘http://d8.dev/node/2’."

It seems as if the page is not redirected on logout the way it is when manually testing with an extremely minimal installation and using the exact same settings (including permissions)/workflow as the tests.

Note all the form-based tests are working as well.

Any idea why this is not working in D8? (It works fine in D7.)

Sponsored by SupremePR
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Why is my functional test not matching my manual testing?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.