class PathMappingTest in Gatsby Live Preview & Incremental Builds 8
Same name in this branch
- 8 tests/src/Unit/PathMappingTest.php \Drupal\Tests\gatsby\Unit\PathMappingTest
- 8 tests/src/Kernel/PathMappingTest.php \Drupal\Tests\gatsby\Kernel\PathMappingTest
Same name and namespace in other branches
- 2.0.x tests/src/Unit/PathMappingTest.php \Drupal\Tests\gatsby\Unit\PathMappingTest
Defines a test for GatsbyPathMapping.
@group gatsby
@covers \Drupal\gatsby\PathMapping
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\gatsby\Unit\PathMappingTest
Expanded class hierarchy of PathMappingTest
File
- tests/
src/ Unit/ PathMappingTest.php, line 15
Namespace
Drupal\Tests\gatsby\UnitView source
class PathMappingTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected $pathmapping;
/**
* Tests GatsbyPathMapping::parsePathMapping.
*
* @dataProvider providerParsePathMapping
*/
public function testParsePathMapping(string $mapping, array $expected) {
$this
->assertEquals($expected, PathMapping::parsePathMapping($mapping));
}
/**
* Data provider for testParsePathMapping.
*
* @return array
* Test cases.
*/
public function providerParsePathMapping() : array {
return [
'empty' => [
'',
[],
],
'single value' => [
'/foo|/bar',
[
'/foo' => '/bar',
],
],
'complex nested path' => [
'/foo/bar/whizz|/bar/biz/bang',
[
'/foo/bar/whizz' => '/bar/biz/bang',
],
],
'multiple values' => [
"/foo|/bar\n/biz|/bang",
[
'/foo' => '/bar',
'/biz' => '/bang',
],
],
'empty line in middle' => [
"/foo|/bar\n\n/biz|/bang",
[
'/foo' => '/bar',
'/biz' => '/bang',
],
],
'empty line at end' => [
"/foo|/bar\n/biz|/bang\n",
[
'/foo' => '/bar',
'/biz' => '/bang',
],
],
'empty line at start' => [
"\n/foo|/bar\n/biz|/bang",
[
'/foo' => '/bar',
'/biz' => '/bang',
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PathMappingTest:: |
protected | property | ||
PathMappingTest:: |
public | function | Data provider for testParsePathMapping. | |
PathMappingTest:: |
public | function | Tests GatsbyPathMapping::parsePathMapping. | |
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 |