function AssertLegacyTraitTest::testAssertOptionSelectedFail

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php \Drupal\Tests\Core\Assert\AssertLegacyTraitTest::testAssertOptionSelectedFail()

@covers ::assertOptionSelected

File

core/tests/Drupal/Tests/Core/Assert/AssertLegacyTraitTest.php, line 184

Class

AssertLegacyTraitTest
@coversDefaultClass \Drupal\FunctionalTests\AssertLegacyTrait @group Assert @group legacy

Namespace

Drupal\Tests\Core\Assert

Code

public function testAssertOptionSelectedFail() {
    $this->expectDeprecation('AssertLegacyTrait::assertOptionSelected() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->optionExists() instead and check the "selected" attribute. See https://www.drupal.org/node/3129738');
    $option_field = $this->prophesize(NodeElement::class);
    $option_field->hasAttribute('selected')
        ->willReturn(FALSE);
    $this->webAssert
        ->optionExists('my_select', 'two')
        ->willReturn($option_field->reveal());
    $this->expectException(ExpectationFailedException::class);
    $this->assertOptionSelected('my_select', 'two');
}

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