Problem/Motivation

For BC reasons we need a method assertNoTitle on AssertLegacyTrait
as well as a new method on \Drupal\Tests\WebAssert called titleNotEquals

Proposed resolution

Remaining tasks

Add a test for titleNotEquals to \Drupal\FunctionalTests\BrowserTestBaseTest

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Issue tags: +Novice
eallison3’s picture

I'm working on this and hope to have a solution within the next few days.

eallison3’s picture

dawehner’s picture

Issue tags: +Needs tests coverage

That itself looks quite fine. One thing though what we should add is some level of test coverage ...

dawehner’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests coverage +Needs tests
dawehner’s picture

Issue summary: View changes

Added a remaining task description.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

eallison3’s picture

Added test for titleNotEquals to \Drupal\FunctionalTests\BrowserTestBaseTest

eallison3’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests +Needs Review
dawehner’s picture

The test looks great!

+++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php
@@ -339,6 +339,21 @@ protected function assertTitle($expected_title) {
+  protected function assertNoTitle($given_title) {

+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -137,6 +137,16 @@ public function testPipeCharInLocator() {
+  public function testTitleNotEquals() {
...
+    $this->assertSession()->titleNotEquals('Not the Title');

What about quickly testing the BC layer as well here?

eallison3’s picture

Status: Needs review » Needs work
eallison3’s picture

Status: Needs work » Needs review

Looks like the failed test was a false alarm.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs Review

Thank you!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

I'm not sure I get the point of the method at all. I certainly don't think we should be putting it in core/tests/Drupal/Tests/WebAssert.php. If you look at the 2 usages in WebTestBase they are both preceded by an assertTitle() so it that works as expected then the assertNoTitle is pointless. I'd rather this patch removed those usages and debated about whether or not we should even be putting this in core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php because I'm not sure we should. This method was added in #345632: SimpleTest: correct assertTitle logic - for completeness.

Negative assertions are tricky and I don't think our test system should be encouraging unnecessary ones.

Here are the current core usages (lol):

    $this->assertTitle(t('Test page | @site-name', array(
      '@site-name' => $this->config('system.site')->get('name'),
    )));
    $this->assertNoTitle('Foo');
    $this->assertTitle(t('Don\'t Panic | @site-name', array('@site-name' => $site_name)), 'The page title contains the escaped character.');
    $this->assertNoTitle(t('Don't Panic | @site-name', array('@site-name' => $site_name)), 'The page title does not contain an encoded character.');
alexpott’s picture

+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -137,6 +137,24 @@ public function testPipeCharInLocator() {
   /**
+   * Tests titleNotEquals() functionality.
+   *
+   * @see \Drupal\Tests\WebAssert::titleNotEquals()
+   */
+  public function testTitleNotEquals() {
+    $this->drupalGet('test-page');
+    $this->assertSession()->titleNotEquals('Not the Title');
+  }
+
+  /**
+   * Tests legacy assertNoTitle() functionality.
+   */
+  public function testAssertNoTitle() {
+    $this->drupalGet('test-page');
+    $this->assertNoTitle('Not the Title');
+  }

Just a thought - if we do go forward with this patch - two separate test installs of Drupal to essentially test the same assertion seems quite wasteful.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

impalash’s picture

impalash’s picture

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Needs work

I agree with @alexpott on #18, let's merge the two test functions.

borisson_’s picture

Status: Needs work » Needs review
FileSize
705 bytes
2.8 KB

Fixed #18.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

Before I start working on is this still needed for 9.5?

Would it be deprecated in 9.5 and removed in 10?

And it will need a CR?

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there was no follow up to #33 going to close for now.

But if still a valid task please please reopen

Thanks everyone!