You are here

ChildSiteTestBase.php in Bakery Single Sign-On System 8.2

File

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

namespace Drupal\Tests\bakery\Functional;

use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\Url;
class ChildSiteTestBase extends BakerySiteTestBase {
  public function setUp() {
    parent::setUp();
    $this
      ->config('bakery.settings')
      ->set('bakery_is_master', 0)
      ->save();
    $this->container
      ->get('router.builder')
      ->rebuild();
  }

  /**
   * Logs a user out of the Mink controlled browser and confirms.
   *
   * Confirms logout by checking the login page.
   */
  protected function drupalLogout() {
    if ($this
      ->config('bakery.settings')
      ->get('subsite_login')) {
      parent::drupalLogout();
    }
    else {

      // Assertions in the parent method won't work because logins are disabled
      // so just skip them.
      $this
        ->drupalGet(Url::fromRoute('user.logout'));

      // @see BrowserTestBase::drupalUserIsLoggedIn()
      unset($this->loggedInUser->sessionId);
      $this->loggedInUser = FALSE;
      \Drupal::currentUser()
        ->setAccount(new AnonymousUserSession());
    }
  }

}

Classes

Namesort descending Description
ChildSiteTestBase