You are here

protected function HttpFetcherTest::setUp in Feeds 8.3

Same name in this branch
  1. 8.3 tests/src/Functional/Feeds/Fetcher/HttpFetcherTest.php \Drupal\Tests\feeds\Functional\Feeds\Fetcher\HttpFetcherTest::setUp()
  2. 8.3 tests/src/Unit/Feeds/Fetcher/HttpFetcherTest.php \Drupal\Tests\feeds\Unit\Feeds\Fetcher\HttpFetcherTest::setUp()

Overrides FeedsBrowserTestBase::setUp

File

tests/src/Functional/Feeds/Fetcher/HttpFetcherTest.php, line 41

Class

HttpFetcherTest
@coversDefaultClass \Drupal\feeds\Feeds\Fetcher\HttpFetcher @group feeds

Namespace

Drupal\Tests\feeds\Functional\Feeds\Fetcher

Code

protected function setUp() {
  parent::setUp();

  // Add body field.
  node_add_body_field($this->nodeType);

  // Add taxonomy reference field.
  Vocabulary::create([
    'vid' => 'tags',
    'name' => 'Tags',
  ])
    ->save();
  $this
    ->createFieldWithStorage('field_tags', [
    'type' => 'entity_reference',
    'label' => 'Tags',
    'storage' => [
      'settings' => [
        'target_type' => 'taxonomy_term',
      ],
      'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ],
    'field' => [
      'settings' => [
        'handler_settings' => [
          'target_bundles' => [
            'tags' => 'tags',
          ],
        ],
      ],
    ],
  ]);

  // Create a feed type.
  $this->feedType = $this
    ->createFeedType([
    'fetcher' => 'http',
    'mappings' => [
      [
        'target' => 'title',
        'map' => [
          'value' => 'title',
        ],
      ],
      [
        'target' => 'body',
        'map' => [
          'value' => 'description',
        ],
      ],
      [
        'target' => 'feeds_item',
        'map' => [
          'guid' => 'guid',
          'url' => 'url',
        ],
        'unique' => [
          'guid' => TRUE,
        ],
      ],
      [
        'target' => 'created',
        'map' => [
          'value' => 'timestamp',
        ],
      ],
      [
        'target' => 'field_tags',
        'map' => [
          'target_id' => 'tags',
        ],
        'settings' => [
          'autocreate' => TRUE,
        ],
      ],
    ],
    'processor_configuration' => [
      'values' => [
        'type' => 'article',
      ],
    ],
    'import_period' => FeedTypeInterface::SCHEDULE_NEVER,
  ]);
  $this
    ->drupalPlaceBlock('local_tasks_block');
  $this
    ->drupalPlaceBlock('local_actions_block');
  $this
    ->drupalPlaceBlock('system_messages_block');
}