View source
<?php
namespace Drupal\Tests\feeds_ex\Functional;
use Drupal\node\Entity\Node;
class FeedTypeEditFormTest extends FeedsExBrowserTestBase {
public function testFeedTypeEdit() {
$this->feedType = $this
->createFeedType([
'parser' => 'xml',
'parser_configuration' => [
'context' => [
'value' => '//item',
],
'sources' => [
'guid' => [
'label' => 'guid',
'value' => 'guid',
],
'title' => [
'label' => 'title',
'value' => 'title',
],
],
],
'custom_sources' => [
'guid' => [
'label' => 'guid',
'value' => 'guid',
'machine_name' => 'guid',
],
'title' => [
'label' => 'title',
'value' => 'title',
'machine_name' => 'title',
],
],
]);
$this
->drupalGet('/admin/structure/feeds/manage/' . $this->feedType
->id());
$edit = [
'processor_configuration[owner_id]' => '',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextContains('Your changes have been saved.');
$feed = $this
->createFeed($this->feedType
->id(), [
'source' => $this
->resourcesUrl() . '/content.xml',
]);
$this
->batchImport($feed);
$this
->assertSession()
->pageTextContains('Created 2 Article items.');
$node1 = Node::load(1);
$this
->assertEquals('1', $node1->feeds_item->guid);
$this
->assertEquals('Lorem ipsum', $node1
->getTitle());
$node2 = Node::load(2);
$this
->assertEquals('2', $node2->feeds_item->guid);
$this
->assertEquals('Ut wisi enim ad minim veniam', $node2
->getTitle());
}
}