You are here

GingerbreadTest.php in Bakery Single Sign-On System 8.2

File

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

namespace Drupal\Tests\bakery\Unit\Cookies;

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

/**
 * @coversDefaultClass \Drupal\bakery\Cookies\Gingerbread
 */
class GingerbreadTest extends UnitTestCase {
  use RemoteCookieTestTrait;
  public function setUp() {
    parent::setUp();
    $this->cookie = Gingerbread::class;
    $this->cookieName = 'gingerbread';
    $this->remotePath = 'bakery/create';
  }
  public function provideTestData() {
    return [
      'basic' => [
        [
          'name' => 'testuser1',
          'or_email' => 1,
          'slave' => 'child.example.com',
          'uid' => 123,
        ],
      ],
      [
        [
          'name' => 'testuser1',
          'or_email' => 0,
          'slave' => 'child.example.com',
          'uid' => 123,
        ],
      ],
    ];
  }

  /**
   * @covers ::getAccountName
   * @covers ::getOrEmail
   * @covers ::getChild
   * @covers ::getChildUid
   * @dataProvider provideTestData
   */
  public function testAccessors($data) {
    $cookie = Gingerbread::fromData($data);
    $this
      ->assertEquals($data['name'], $cookie
      ->getAccountName());
    $this
      ->assertEquals($data['or_email'], $cookie
      ->getOrEmail());
    $this
      ->assertEquals($data['slave'], $cookie
      ->getChild());
    $this
      ->assertEquals($data['uid'], $cookie
      ->getChildUid());
  }

}

Classes

Namesort descending Description
GingerbreadTest @coversDefaultClass \Drupal\bakery\Cookies\Gingerbread