You are here

class UnpublishedNodesRedirectTest in Unpublished Nodes Redirect 8

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

Test for Unpublished nodes redirect module.

@group unpublished_nodes_redirect

Hierarchy

Expanded class hierarchy of UnpublishedNodesRedirectTest

File

tests/src/Unit/UnpublishedNodesRedirectTest.php, line 13

Namespace

Drupal\Tests\unpublished_nodes_redirect\Unit
View source
class UnpublishedNodesRedirectTest extends UnitTestCase {

  /**
   *
   */
  protected function setUp() {
    $this->utils = new Utils();
    parent::setUp();
  }

  /**
   * Tests getting node type keys.
   */
  public function testGetNodeTypeKey() {
    $this
      ->assertEquals('content_type_name_unpublished_redirect_path', $this->utils
      ->getNodeTypeKey('content_type_name'));
  }

  /**
   * Tests getting response code keys.
   */
  public function testGetResponseCodeKey() {
    $this
      ->assertEquals('content_type_name_unpublished_redirect_response_code', $this->utils
      ->getResponseCodeKey('content_type_name'));
  }

  /**
   * Tests checks before redirect.
   */
  public function testChecksBeforeRedirect() {
    $this
      ->assertTrue(TRUE, $this->utils
      ->checksBeforeRedirect(0, TRUE, '', 'test/path', 301));
    $this
      ->assertFalse(FALSE, $this->utils
      ->checksBeforeRedirect(1, TRUE, '', 'test/path', 301));
    $this
      ->assertFalse(FALSE, $this->utils
      ->checksBeforeRedirect(0, FALSE, '', 'test/path', 301));
    $this
      ->assertFalse(FALSE, $this->utils
      ->checksBeforeRedirect(0, FALSE, '', '', 301));
    $this
      ->assertFalse(FALSE, $this->utils
      ->checksBeforeRedirect(0, FALSE, '', 'test/path', 0));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
UnpublishedNodesRedirectTest::setUp protected function Overrides UnitTestCase::setUp
UnpublishedNodesRedirectTest::testChecksBeforeRedirect public function Tests checks before redirect.
UnpublishedNodesRedirectTest::testGetNodeTypeKey public function Tests getting node type keys.
UnpublishedNodesRedirectTest::testGetResponseCodeKey public function Tests getting response code keys.