You are here

class LinkCheckerResponseCodesTest in Link checker 8

Tests \Drupal\linkchecker\LinkCheckerResponseCodes.

@group linkchecker

@coversDefaultClass \Drupal\linkchecker\LinkCheckerResponseCodes

Hierarchy

Expanded class hierarchy of LinkCheckerResponseCodesTest

File

tests/src/Unit/LinkCheckerResponseCodesTest.php, line 15

Namespace

Drupal\Tests\linkchecker\Unit
View source
class LinkCheckerResponseCodesTest extends UnitTestCase {

  /**
   * The linkchecker response codes service.
   *
   * @var \Drupal\linkchecker\LinkCheckerResponseCodes
   */
  protected $linkCheckerResponseCodes;

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this->linkCheckerResponseCodes = new LinkCheckerResponseCodes();
  }

  /**
   * Tests the the ::isValid method.
   *
   * @param int $code
   *   The HTTP response code.
   * @param bool $result
   *   The expected result from calling the function.
   *
   * @dataProvider isValidDataProvider
   *
   * @covers ::isValid
   */
  public function testIsValid(int $code, bool $result) {
    $this
      ->assertEquals($result, $this->linkCheckerResponseCodes
      ->isValid($code));
  }

  /**
   * Data provider for testIsValid().
   *
   * @see testIsValid()
   */
  public function isValidDataProvider() {
    return [
      [
        100,
        TRUE,
      ],
      [
        101,
        TRUE,
      ],
      [
        102,
        FALSE,
      ],
      [
        103,
        FALSE,
      ],
      [
        200,
        TRUE,
      ],
      [
        201,
        TRUE,
      ],
      [
        202,
        TRUE,
      ],
      [
        203,
        TRUE,
      ],
      [
        204,
        TRUE,
      ],
      [
        205,
        TRUE,
      ],
      [
        206,
        TRUE,
      ],
      [
        207,
        FALSE,
      ],
      [
        208,
        FALSE,
      ],
      [
        226,
        FALSE,
      ],
      [
        300,
        TRUE,
      ],
      [
        301,
        TRUE,
      ],
      [
        302,
        TRUE,
      ],
      [
        303,
        TRUE,
      ],
      [
        304,
        TRUE,
      ],
      [
        305,
        TRUE,
      ],
      [
        306,
        FALSE,
      ],
      [
        307,
        TRUE,
      ],
      [
        308,
        FALSE,
      ],
      [
        400,
        TRUE,
      ],
      [
        401,
        TRUE,
      ],
      [
        402,
        TRUE,
      ],
      [
        403,
        TRUE,
      ],
      [
        404,
        TRUE,
      ],
      [
        405,
        TRUE,
      ],
      [
        406,
        TRUE,
      ],
      [
        407,
        TRUE,
      ],
      [
        408,
        TRUE,
      ],
      [
        409,
        TRUE,
      ],
      [
        410,
        TRUE,
      ],
      [
        411,
        TRUE,
      ],
      [
        412,
        TRUE,
      ],
      [
        413,
        TRUE,
      ],
      [
        414,
        TRUE,
      ],
      [
        415,
        TRUE,
      ],
      [
        416,
        TRUE,
      ],
      [
        417,
        TRUE,
      ],
      [
        418,
        FALSE,
      ],
      [
        421,
        FALSE,
      ],
      [
        422,
        FALSE,
      ],
      [
        423,
        FALSE,
      ],
      [
        424,
        FALSE,
      ],
      [
        425,
        FALSE,
      ],
      [
        426,
        FALSE,
      ],
      [
        428,
        FALSE,
      ],
      [
        429,
        FALSE,
      ],
      [
        431,
        FALSE,
      ],
      [
        451,
        FALSE,
      ],
      [
        500,
        TRUE,
      ],
      [
        501,
        TRUE,
      ],
      [
        502,
        TRUE,
      ],
      [
        503,
        TRUE,
      ],
      [
        504,
        TRUE,
      ],
      [
        505,
        TRUE,
      ],
      [
        506,
        FALSE,
      ],
      [
        507,
        FALSE,
      ],
      [
        508,
        FALSE,
      ],
      [
        510,
        FALSE,
      ],
      [
        511,
        FALSE,
      ],
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LinkCheckerResponseCodesTest::$linkCheckerResponseCodes protected property The linkchecker response codes service.
LinkCheckerResponseCodesTest::isValidDataProvider public function Data provider for testIsValid().
LinkCheckerResponseCodesTest::setUp public function Overrides UnitTestCase::setUp
LinkCheckerResponseCodesTest::testIsValid public function Tests the the ::isValid method.
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.