class Fast404Test in Fast 404 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/Fast404Test.php \Drupal\Tests\fast404\Unit\Fast404Test
Tests Fast404 methods.
@coversDefaultClass \Drupal\fast404\Fast404 @group fast404
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\fast404\Unit\Fast404Test
Expanded class hierarchy of Fast404Test
File
- tests/
src/ Unit/ Fast404Test.php, line 13
Namespace
Drupal\Tests\fast404\UnitView source
class Fast404Test extends UnitTestCase {
/**
* Creates a fast404 object to test.
*
* @return \Drupal\fast404\Fast404
* A mock fast404 object to test.
*/
protected function getFast404() {
$requestStub = $this
->getMockBuilder('\\Symfony\\Component\\HttpFoundation\\Request')
->disableOriginalConstructor()
->getMock();
$fast404 = $this
->getMockBuilder('\\Drupal\\fast404\\Fast404')
->setConstructorArgs([
$requestStub,
])
->setMethods([
'isCli',
])
->getMock();
$fast404
->method('isCli')
->willReturn(FALSE);
return $fast404;
}
/**
* Tests blocking a path.
*
* @covers ::blockPath
*/
public function testBlockPath() {
$fast404 = $this
->getFast404();
// Default value is FALSE for respond404.
$this
->assertAttributeEquals(FALSE, 'respond404', $fast404);
$fast404
->blockPath();
// A block path's value is TRUE for respond404.
$this
->assertAttributeEquals(TRUE, 'respond404', $fast404);
}
/**
* Tests checking if a path is blocked.
*
* @covers ::isPathBlocked
*/
public function testIsPathBlocked() {
$fast404 = $this
->getFast404();
$this
->assertEquals(FALSE, $fast404
->isPathBlocked());
// If CLI, return FALSE regardless.
$fast404
->method('isCli')
->willReturn(TRUE);
$this
->assertEquals(FALSE, $fast404
->isPathBlocked());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Fast404Test:: |
protected | function | Creates a fast404 object to test. | |
Fast404Test:: |
public | function | Tests blocking a path. | |
Fast404Test:: |
public | function | Tests checking if a path is blocked. | |
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 |