JsonPathLinesParserTest.php in Feeds extensible parsers 8
File
tests/src/FunctionalJavascript/Feeds/Parser/JsonPathLinesParserTest.php
View source
<?php
namespace Drupal\Tests\feeds_ex\FunctionalJavascript\Feeds\Parser;
use Drupal\feeds\Entity\Feed;
use Drupal\node\Entity\Node;
class JsonPathLinesParserTest extends ParserTestBase {
protected $parserId = 'jsonpathlines';
public function testMapCustomSource() {
$this
->addMappings($this->feedType
->id(), [
[
'target' => 'title',
'map' => [
'value' => [
'value' => 'name',
'machine_name' => 'name_',
],
],
'unique' => [
'value' => TRUE,
],
],
[
'target' => 'body',
'map' => [
'value' => [
'value' => 'wins.0.1',
'machine_name' => 'wins_0_1',
],
],
],
]);
$edit = [
'title[0][value]' => 'Feed 1',
'plugin[fetcher][source]' => $this
->resourcesUrl() . '/test.jsonl',
];
$this
->drupalGet('/feed/add/' . $this->feedType
->id());
$this
->submitFormWithDropButton($edit, 'Save');
$feed = Feed::load(1);
$feed
->import();
$node1 = Node::load(1);
$this
->assertEquals('Gilbert', $node1
->getTitle());
$this
->assertEquals('7♣', $node1->body->value);
}
}