function WebAssertTest::testAddressEquals

Same name in other branches
  1. 10 core/tests/Drupal/FunctionalTests/WebAssertTest.php \Drupal\FunctionalTests\WebAssertTest::testAddressEquals()
  2. 11.x core/tests/Drupal/FunctionalTests/WebAssertTest.php \Drupal\FunctionalTests\WebAssertTest::testAddressEquals()
  3. 10 core/tests/Drupal/Tests/Core/Test/WebAssertTest.php \Drupal\Tests\Core\Test\WebAssertTest::testAddressEquals()
  4. 11.x core/tests/Drupal/Tests/Core/Test/WebAssertTest.php \Drupal\Tests\Core\Test\WebAssertTest::testAddressEquals()

@covers ::addressEquals

File

core/tests/Drupal/FunctionalTests/WebAssertTest.php, line 104

Class

WebAssertTest
Tests WebAssert functionality.

Namespace

Drupal\FunctionalTests

Code

public function testAddressEquals() : void {
    $this->drupalGet('test-page');
    $this->assertSession()
        ->addressEquals('test-page');
    $this->assertSession()
        ->addressEquals('test-page?');
    $this->assertSession()
        ->addressNotEquals('test-page?a=b');
    $this->assertSession()
        ->addressNotEquals('other-page');
    $this->drupalGet('test-page', [
        'query' => [
            'a' => 'b',
            'c' => 'd',
        ],
    ]);
    $this->assertSession()
        ->addressEquals('test-page');
    $this->assertSession()
        ->addressEquals('test-page?a=b&c=d');
    $this->assertSession()
        ->addressEquals(Url::fromRoute('test_page_test.test_page', [], [
        'query' => [
            'a' => 'b',
            'c' => 'd',
        ],
    ]));
    $this->assertSession()
        ->addressNotEquals('test-page?c=d&a=b');
    $this->assertSession()
        ->addressNotEquals('test-page?a=b');
    $this->assertSession()
        ->addressNotEquals('test-page?a=b&c=d&e=f');
    $this->assertSession()
        ->addressNotEquals('other-page');
    $this->assertSession()
        ->addressNotEquals('other-page?a=b&c=d');
    $this->expectException(ExpectationException::class);
    $this->expectExceptionMessage('Current page is "/test-page?a=b&c=d", but "/test-page?a=b&c=e" expected.');
    $this->assertSession()
        ->addressEquals('test-page?a=b&c=e');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.