You are here

StroopwafelTest.php in Bakery Single Sign-On System 8.2

File

tests/src/Unit/Cookies/StroopwafelTest.php
View source
<?php

namespace Drupal\Tests\bakery\Unit\Cookies;

use Drupal\bakery\Cookies\Gingerbread;
use Drupal\bakery\Cookies\Stroopwafel;
use Drupal\Tests\bakery\Traits\RemoteCookieTestTrait;
use Drupal\Tests\UnitTestCase;

/**
 * @coversDefaultClass \Drupal\bakery\Cookies\Stroopwafel
 */
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());
  }

}

Classes

Namesort descending Description
StroopwafelTest @coversDefaultClass \Drupal\bakery\Cookies\Stroopwafel