public function PathTest::testImportPathauto in Feeds 8.3
Tests importing with and without automatic aliases.
File
- tests/
src/ Kernel/ Feeds/ Target/ PathTest.php, line 138
Class
- PathTest
- @coversDefaultClass \Drupal\feeds\Feeds\Target\Path @group feeds
Namespace
Drupal\Tests\feeds\Kernel\Feeds\TargetCode
public function testImportPathauto() {
$this
->installPathauto();
// Create a feed type with mapping to pathauto.
$feed_type = $this
->createFeedTypeForCsv([
'title' => 'title',
'alias' => 'alias',
'epsilon' => 'epsilon',
]);
$feed_type
->addMapping([
'target' => 'path',
'map' => [
'alias' => 'alias',
'pathauto' => 'epsilon',
],
]);
$feed_type
->save();
// Import.
$feed = $this
->createFeed($feed_type
->id(), [
'source' => $this
->resourcesPath() . '/csv/content.csv',
]);
$feed
->import();
// The first item has automatic alias enabled. The second one has not.
$expected = [
1 => '/content/lorem-ipsum',
2 => '/ut-wisi-enim',
];
foreach ($expected as $nid => $value) {
$node = Node::load($nid);
$this
->assertEquals($value, $node->path->alias);
}
}