class CasRedirectDataTest in CAS 8
Same name and namespace in other branches
- 2.x tests/src/Unit/CasRedirectDataTest.php \Drupal\Tests\cas\Unit\CasRedirectDataTest
 
CasRedirectData unit tests.
@group cas
@coversDefaultClass \Drupal\cas\CasRedirectData
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\cas\Unit\CasRedirectDataTest
 
 
Expanded class hierarchy of CasRedirectDataTest
File
- tests/
src/ Unit/ CasRedirectDataTest.php, line 17  
Namespace
Drupal\Tests\cas\UnitView 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
| 
            Name | 
                  Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| 
            CasRedirectDataTest:: | 
                  public | function | Test Force/allow redirectors. | |
| 
            CasRedirectDataTest:: | 
                  public | function | Test Caceable getter and setter. | |
| 
            CasRedirectDataTest:: | 
                  public | function | Test the access methods. | |
| 
            CasRedirectDataTest:: | 
                  public | function | Test Service parameter setters and getters. | |
| 
            PhpunitCompatibilityTrait:: | 
                  public | function | Returns a mock object for the specified class using the available method. | |
| 
            PhpunitCompatibilityTrait:: | 
                  public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
| 
            UnitTestCase:: | 
                  protected | property | The random generator. | |
| 
            UnitTestCase:: | 
                  protected | property | The app root. | 1 | 
| 
            UnitTestCase:: | 
                  protected | function | Asserts if two arrays are equal by sorting them first. | |
| 
            UnitTestCase:: | 
                  protected | function | Mocks a block with a block plugin. | 1 | 
| 
            UnitTestCase:: | 
                  protected | function | Returns a stub class resolver. | |
| 
            UnitTestCase:: | 
                  public | function | Returns a stub config factory that behaves according to the passed array. | |
| 
            UnitTestCase:: | 
                  public | function | Returns a stub config storage that returns the supplied configuration. | |
| 
            UnitTestCase:: | 
                  protected | function | Sets up a container with a cache tags invalidator. | |
| 
            UnitTestCase:: | 
                  protected | function | Gets the random generator for the utility methods. | |
| 
            UnitTestCase:: | 
                  public | function | Returns a stub translation manager that just returns the passed string. | |
| 
            UnitTestCase:: | 
                  public | function | Generates a unique random string containing letters and numbers. | |
| 
            UnitTestCase:: | 
                  protected | function | 340 |