You are here

class CasRedirectDataTest in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/CasRedirectDataTest.php \Drupal\Tests\cas\Unit\CasRedirectDataTest

CasRedirectData unit tests.

@group cas

@coversDefaultClass \Drupal\cas\CasRedirectData

Hierarchy

Expanded class hierarchy of CasRedirectDataTest

File

tests/src/Unit/CasRedirectDataTest.php, line 17

Namespace

Drupal\Tests\cas\Unit
View source
class CasRedirectDataTest extends UnitTestCase {

  /**
   * Test the access methods.
   *
   * @covers ::setParameter
   * @covers ::getParameter
   * @covers ::getAllParameters
   */
  public function testParameters() {

    // Set the base login uri.
    $data = new CasRedirectData();

    // Test gateway set.
    $data
      ->setParameter('gateway', 'true');
    $parms = $data
      ->getAllParameters();
    $this
      ->assertEquals('true', $parms['gateway']);

    // Test gateway removal.
    $data
      ->setParameter('gateway', NULL);
    $parms = $data
      ->getAllParameters();
    $this
      ->assertArrayNotHasKey('gateway', $parms, 'Setvalues of null clear parmaters');
  }

  /**
   * Test Service parameter setters and getters.
   *
   * @covers ::setServiceParameter
   * @covers ::getServiceParameter
   * @covers ::getAllServiceParameters
   */
  public function testServiceParmaeters() {
    $data = new CasRedirectData();
    $data
      ->setServiceParameter('returnto', 'node/1');
    $parms = $data
      ->getAllServiceParameters();
    $this
      ->assertEquals('node/1', $parms['returnto']);
    $this
      ->assertEquals('node/1', $data
      ->getServiceParameter('returnto'), 'Getter');
    $data
      ->setServiceParameter('returnto', NULL);
    $parms = $data
      ->getAllServiceParameters();
    $this
      ->assertArrayNotHasKey('returnto', $parms, 'Service parameter removal');
  }

  /**
   * Test Force/allow redirectors.
   *
   * @covers ::willRedirect
   * @covers ::forceRedirection
   * @covers ::preventRedirection
   */
  public function testAllowRedirection() {
    $data = new CasRedirectData();
    $this
      ->assertTrue($data
      ->willRedirect(), 'Default Value');
    $data
      ->forceRedirection();
    $this
      ->assertTrue($data
      ->willRedirect(), 'Forced');
    $data
      ->preventRedirection();
    $this
      ->assertFalse($data
      ->willRedirect(), 'Prevented');
  }

  /**
   * Test Caceable getter and setter.
   */
  public function testCachable() {
    $data = new CasRedirectData();
    $this
      ->assertFalse($data
      ->getIsCacheable(), 'Default Value');
    $data
      ->setIsCacheable(TRUE);
    $this
      ->assertTrue($data
      ->getIsCacheable(), 'Modified value');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CasRedirectDataTest::testAllowRedirection public function Test Force/allow redirectors.
CasRedirectDataTest::testCachable public function Test Caceable getter and setter.
CasRedirectDataTest::testParameters public function Test the access methods.
CasRedirectDataTest::testServiceParmaeters public function Test Service parameter setters and getters.
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.
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.
UnitTestCase::setUp protected function 340