You are here

ChildSitePagesTest.php in Bakery Single Sign-On System 8.2

File

tests/src/Functional/ChildSitePagesTest.php
View source
<?php

namespace Drupal\Tests\bakery\Functional;

use Drupal\bakery\Cookies\ChocolateChip;
class ChildSitePagesTest extends ChildSiteTestBase {
  protected $defaultTheme = 'stark';

  /**
   * Test some pages.
   */
  public function testPages() {
    $assert_session = $this
      ->assertSession();
    $this
      ->drupalGet('/bakery/repair');
    $assert_session
      ->statusCodeEquals(403);

    // Trigger a bad account to repair.
    $account = $this
      ->createUser([], NULL, FALSE, [
      'mail' => '',
    ]);
    $this
      ->bakeCookie(new ChocolateChip($account
      ->getAccountName(), 'test@example.com', $account
      ->getInitialEmail(), '1'));
    $this
      ->drupalGet('');
    $assert_session
      ->pageTextContains('Would you like to try to repair it yourself?');
    $assert_session
      ->linkByHrefExists('/bakery/repair');
    $this
      ->drupalGet('/bakery/repair');

    // Repair account and confirm it gets logged in.
    $this
      ->submitForm([
      'pass' => $account
        ->getPassword(),
    ], 'Repair account');
    $assert_session
      ->statusCodeEquals(200);
    $assert_session
      ->pageTextContains($account
      ->getAccountName());

    // Repaired account able to login.
    $this
      ->drupalLogout();
    $this
      ->bakeCookie(new ChocolateChip($account
      ->getAccountName(), 'test@example.com', $account
      ->getInitialEmail(), '1'));
    $this
      ->drupalGet('');
    $assert_session
      ->responseContains($account
      ->getAccountName());
  }

}

Classes

Namesort descending Description
ChildSitePagesTest