You are here

trait CookieTestTrait in Bakery Single Sign-On System 8.2

Hierarchy

3 files declare their use of CookieTestTrait
ChocolateChipTest.php in tests/src/Unit/Cookies/ChocolateChipTest.php
GingerbreadReturnTest.php in tests/src/Unit/Cookies/GingerbreadReturnTest.php
OatmealCookieTest.php in tests/src/Unit/Cookies/OatmealCookieTest.php

File

tests/src/Traits/CookieTestTrait.php, line 11

Namespace

Drupal\Tests\bakery\Traits
View source
trait CookieTestTrait {

  /**
   * @var string
   */
  protected $cookie;

  /**
   * @var string
   */
  protected $cookieName;
  protected $dataExtra = [];

  /**
   * @var \Drupal\bakery\Kitchen|\Prophecy\Prophecy\ObjectProphecy
   */
  protected $kitchenService;

  /**
   * @var \Drupal\bakery\BakeryService|\Prophecy\Prophecy\ObjectProphecy
   */
  protected $bakeryService;

  /**
   * @covers ::__construct
   * @covers ::toData
   * @covers ::fromData
   * @dataProvider provideTestData
   */
  public function testFromData($data) {
    $this
      ->assertEquals($data + $this->dataExtra, $this->cookie::fromData($data)
      ->toData());
  }
  public abstract function provideTestData();

  /**
   * @covers ::getName
   */
  public function testGetName() {
    $this
      ->assertEquals($this->cookieName, $this->cookie::getName());
  }
  protected function setupBrowserContainer() {
    $container = new Container();
    $this->kitchenService = $this
      ->prophesize(Kitchen::class);
    $this->bakeryService = $this
      ->prophesize(BakeryService::class);
    $this->kitchenService
      ->cookieName(Argument::any())
      ->willReturn($this->cookieName);
    $container
      ->set('bakery.kitchen', $this->kitchenService
      ->reveal());
    $container
      ->set('bakery.bakery_service', $this->bakeryService
      ->reveal());
    \Drupal::setContainer($container);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CookieTestTrait::$bakeryService protected property
CookieTestTrait::$cookie protected property
CookieTestTrait::$cookieName protected property
CookieTestTrait::$dataExtra protected property
CookieTestTrait::$kitchenService protected property
CookieTestTrait::provideTestData abstract public function 5
CookieTestTrait::setupBrowserContainer protected function
CookieTestTrait::testFromData public function @covers ::__construct @covers ::toData @covers ::fromData @dataProvider provideTestData
CookieTestTrait::testGetName public function @covers ::getName