JsonPathParserTest.php in Feeds extensible parsers 8
File
tests/src/Functional/Feeds/Parser/JsonPathParserTest.php
View source
<?php
namespace Drupal\Tests\feeds_ex\Functional\Feeds\Parser;
class JsonPathParserTest extends ParserTestBase {
use ContextTestTrait;
protected $parserId = 'jsonpath';
public function dataProviderValidContext() {
return [
[
'$.items.*',
],
];
}
public function dataProviderInvalidContext() {
return [
[
'.hello*',
'Unable to parse token hello* in expression: .hello*',
],
[
'!!',
'Unable to parse token !! in expression: .!!',
],
];
}
public function testInvalidMappingSource() {
$this
->drupalGet('/admin/structure/feeds/manage/' . $this->feedType
->id() . '/mapping');
$edit = [
'context' => '$.items.*',
];
$this
->drupalPostForm('/admin/structure/feeds/manage/' . $this->feedType
->id() . '/mapping', $edit, 'Save');
$edit = [
'mappings[1][map][value][select]' => '__new',
'mappings[1][map][value][__new][value]' => '.hello*',
'mappings[1][map][value][__new][machine_name]' => '_hello_',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$this
->assertSession()
->pageTextContains('Unable to parse token hello* in expression: .hello*');
$this->feedType = $this
->reloadEntity($this->feedType);
$this
->assertEquals([], $this->feedType
->getParser()
->getConfiguration('sources'));
}
}