BrowserCookieTraitTest.php in Bakery Single Sign-On System 8.2
Namespace
Drupal\Tests\bakery\Unit\CookiesFile
tests/src/Unit/Cookies/BrowserCookieTraitTest.phpView source
<?php
namespace Drupal\Tests\bakery\Unit\Cookies;
use Drupal\bakery\BakeryService;
use Drupal\bakery\Cookies\BrowserCookieTrait;
use Drupal\bakery\Kitchen;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\bakery\Cookies\BrowserCookieTrait
*/
class BrowserCookieTraitTest extends UnitTestCase {
/**
* @var \Drupal\bakery\Kitchen|\Prophecy\Prophecy\ObjectProphecy
*/
protected $kitchenService;
/**
* @var \Drupal\bakery\BakeryService|\Prophecy\Prophecy\ObjectProphecy
*/
protected $bakeryService;
public function setUp() {
parent::setUp();
$container = new Container();
$this->kitchenService = $this
->prophesize(Kitchen::class);
$this->bakeryService = $this
->prophesize(BakeryService::class);
$container
->set('bakery.kitchen', $this->kitchenService
->reveal());
$container
->set('bakery.bakery_service', $this->bakeryService
->reveal());
\Drupal::setContainer($container);
}
/**
* @covers ::getIsMain
* @covers ::getBakeryService
*/
public function testGetIsMain() {
$this->bakeryService
->isMain()
->shouldBeCalledOnce()
->willReturn(TRUE);
$this
->assertTrue((new class {
use BrowserCookieTrait;
public function test() {
return $this
->getIsMain();
}
})
->test());
}
/**
* @covers ::cookieName
* @covers ::getBakeryKitchen
*/
public function testCookieName() {
$this->kitchenService
->cookieName('test')
->shouldBeCalledOnce()
->willReturn('jibberish');
$this
->assertEquals('jibberish', (new class {
use BrowserCookieTrait;
public function test() {
return $this
->cookieName('test');
}
})
->test());
}
}
Classes
Name![]() |
Description |
---|---|
BrowserCookieTraitTest | @coversDefaultClass \Drupal\bakery\Cookies\BrowserCookieTrait |