You are here

protected function FeedsExHtmlTests::addExpression in Feeds extensible parsers 7

Same name and namespace in other branches
  1. 7.2 src/Tests/FeedsExHtml.test \FeedsExHtmlTests::addExpression()

Adds an expression.

Parameters

string $id: The importer id.

string $value: The expression value.

array $settings: (optional) Settings to configure the expression. Defaults to an empty array.

1 call to FeedsExHtmlTests::addExpression()
FeedsExHtmlTests::test in src/Tests/FeedsExHtml.test
Tests the full import process.

File

src/Tests/FeedsExHtml.test, line 340

Class

FeedsExHtmlTests
Integration tests for FeedsExHtml.

Code

protected function addExpression($id, $value, array $settings = array()) {
  $importer = feeds_importer($id);
  $config = $importer->parser
    ->getConfig();
  if (!isset($settings['weight'])) {
    $weight = end($config['sources']);
    $weight = $weight ? $weight['weight'] + 1 : 0;
    $settings['weight'] = $weight;
  }
  $settings += array(
    'raw' => 0,
    'debug' => 0,
  );
  $machine_name = strtolower($this
    ->randomName());
  $config['sources'][$machine_name] = array(
    'name' => $this
      ->randomString(),
    'value' => $value,
  ) + $settings;
  $importer->parser
    ->setConfig($config);
  $importer
    ->save();
  return $machine_name;
}