You are here

public function AgreementTestBase::assertAgreed in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/AgreementTestBase.php \Drupal\Tests\agreement\Functional\AgreementTestBase::assertAgreed()

Asserts that the user has agreed to the agreement.

Parameters

\Drupal\agreement\Entity\Agreement $agreement: The agreement to agree to.

Throws

\Behat\Mink\Exception\ResponseTextException

8 calls to AgreementTestBase::assertAgreed()
AgreementAnonymousTest::testAgreement in tests/src/Functional/AgreementAnonymousTest.php
Tests agreement as anonymous user.
AgreementCustomFrequencyTest::testAgreement in tests/src/Functional/AgreementCustomFrequencyTest.php
Asserts agreement functionality.
AgreementCustomUnprivilegedUserTest::testAgreementDestination in tests/src/Functional/AgreementCustomUnprivilegedUserTest.php
Tests the agreement destination functionality.
AgreementCustomUnprivilegedUserTest::testAgreementFrequency in tests/src/Functional/AgreementCustomUnprivilegedUserTest.php
Asserts the agreement frequency option.
AgreementDefaultsPrivilegedUserTest::testAgreement in tests/src/Functional/AgreementDefaultsPrivilegedUserTest.php
Asserts that the default settings work for the admin user.

... See full list

1 method overrides AgreementTestBase::assertAgreed()
AgreementMultilingualTest::assertAgreed in tests/src/Functional/AgreementMultilingualTest.php
Asserts that the user has agreed to the agreement.

File

tests/src/Functional/AgreementTestBase.php, line 222

Class

AgreementTestBase
Tests the agreement functionality.

Namespace

Drupal\Tests\agreement\Functional

Code

public function assertAgreed(Agreement $agreement) {
  $settings = $agreement
    ->getSettings();
  $this
    ->drupalGet($agreement
    ->get('path'));
  $this
    ->submitForm([
    'agree' => 1,
  ], $settings['submit']);

  // Check for redirects. It's odd that drupalPostForm doesn't handle this but
  // drupalGet does.
  if ($this
    ->checkForMetaRefresh()) {
    $this->metaRefreshCount = 0;
  }
  $this
    ->assertSession()
    ->pageTextContains($settings['success']);
  $this
    ->assertNotAgreementPage($agreement);
}