public function PathMappingTest::testGetPath in Gatsby Live Preview & Incremental Builds 8
Same name and namespace in other branches
- 2.0.x tests/src/Kernel/PathMappingTest.php \Drupal\Tests\gatsby\Kernel\PathMappingTest::testGetPath()
Tests getPath method.
File
- tests/
src/ Kernel/ PathMappingTest.php, line 54
Class
- PathMappingTest
- Defines tests for getPath method in PathMapping.
Namespace
Drupal\Tests\gatsby\KernelCode
public function testGetPath() {
$config_factory = \Drupal::configFactory();
$config_factory
->getEditable('gatsby.settings')
->set('path_mapping', "/foo|/bar\n/biz|/bang")
->save();
$config_factory
->getEditable('system.site')
->set('page.front', '/hometest')
->save(TRUE);
$path = [
'/hello' => '/hello',
'/foo' => '/bar',
'/hometest' => '',
];
$owner = $this
->createUser();
foreach ($path as $drupal_path => $gatsby_path) {
$node = $this
->createNode([
'title' => 'test',
'type' => 'page',
'uid' => $owner,
'path' => [
'alias' => $drupal_path,
],
]);
$node
->save();
$this
->assertEquals($gatsby_path, $this->container
->get('gatsby.path_mapping')
->getPath($node));
}
}