OatmealCookieTest.php in Bakery Single Sign-On System 8.2
File
tests/src/Unit/Cookies/OatmealCookieTest.php
View source
<?php
namespace Drupal\Tests\bakery\Unit\Cookies;
use Drupal\bakery\Cookies\OatmealCookie;
use Drupal\Tests\bakery\Traits\CookieTestTrait;
use Drupal\Tests\UnitTestCase;
class OatmealCookieTest extends UnitTestCase {
use CookieTestTrait {
testFromData as traitFromDataTest;
testGetName as traitGetNameTest;
}
public function setUp() {
parent::setUp();
$this->cookie = OatmealCookie::class;
$this->cookieName = 'OATMEALCOOKIE';
$this->dataExtra = [
'calories' => 320,
];
$this
->setupBrowserContainer();
}
public function provideTestData() {
return [
'main' => [
[
'name' => 'testuser1',
'data' => 'asdfasdfasdfa',
'master' => 1,
],
],
'child' => [
[
'name' => 'testuser1',
'data' => 'asdfasdfasdfa',
'master' => 0,
],
],
];
}
public function testFromData($data) {
if ($data['master']) {
$this->bakeryService
->isMain()
->willReturn(1);
$this->bakeryService
->isChild()
->willReturn(0);
}
else {
$this->bakeryService
->isMain()
->willReturn(0);
$this->bakeryService
->isChild()
->willReturn(1);
$this->dataExtra += [
'slave' => '/',
];
}
$this
->traitFromDataTest($data);
}
}