You are here

class StroopwafelTest in Bakery Single Sign-On System 8.2

@coversDefaultClass \Drupal\bakery\Cookies\Stroopwafel

Hierarchy

Expanded class hierarchy of StroopwafelTest

File

tests/src/Unit/Cookies/StroopwafelTest.php, line 14

Namespace

Drupal\Tests\bakery\Unit\Cookies
View source
class StroopwafelTest extends UnitTestCase {
  use RemoteCookieTestTrait;
  public function setUp() {
    parent::setUp();
    $this->cookie = Stroopwafel::class;
    $this->cookieName = 'stroopwafel';
    $this->remotePath = 'bakery/update';

    // Legacy category property.
    $this->dataExtra = [
      'category' => 'account',
    ];
  }
  public function provideTestData() {
    return [
      'basic' => [
        [
          'uid' => 123,
          'data' => serialize([
            'name' => 'testuser',
          ]),
        ],
      ],
    ];
  }

  /**
   * @covers ::getUid
   * @covers ::getData
   * @dataProvider provideTestData
   */
  public function testAccessors($data) {
    $cookie = Stroopwafel::fromData($data);
    $this
      ->assertEquals($data['uid'], $cookie
      ->getUid());
    $this
      ->assertEquals(unserialize($data['data']), $cookie
      ->getData());
  }

}

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::setupBrowserContainer protected function
CookieTestTrait::testFromData public function @covers ::__construct @covers ::toData @covers ::fromData @dataProvider provideTestData
CookieTestTrait::testGetName public function @covers ::getName
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
RemoteCookieTestTrait::$remotePath protected property
RemoteCookieTestTrait::testGetPath public function @covers ::getPath @dataProvider provideTestData
StroopwafelTest::provideTestData public function Overrides CookieTestTrait::provideTestData
StroopwafelTest::setUp public function Overrides UnitTestCase::setUp
StroopwafelTest::testAccessors public function @covers ::getUid @covers ::getData @dataProvider provideTestData
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.