You are here

public function FeedsExQueryPathHtmlUnitTests::testSimpleParsing in Feeds extensible parsers 7.2

Tests simple parsing.

File

src/Tests/FeedsExQueryPathHtml.test, line 45
Contains tests for FeedsExQueryPathHtml.

Class

FeedsExQueryPathHtmlUnitTests
Unit tests for FeedsExQueryPathHtml.

Code

public function testSimpleParsing() {
  $parser = FeedsConfigurable::instance('FeedsExQueryPathHtml', 'test_parser');
  $fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.html'));
  $parser
    ->setConfig(array(
    'context' => array(
      'value' => '.post',
    ),
    'sources' => array(
      'title' => array(
        'name' => 'Title',
        'value' => 'h3',
        'attribute' => '',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'p',
        'attribute' => '',
      ),
    ),
  ));
  $result = $parser
    ->parse($this->source, $fetcher_result);
  $this
    ->assertEqual(count($result->items), 3, format_string('@count items parsed.', array(
    '@count' => count($result->items),
  )));
  $this
    ->assertEqual('I am a title<thing>Stuff</thing>', $result->items[0]['title']);
  $this
    ->assertEqual('I am a description0', $result->items[0]['description']);
  $this
    ->assertEqual('I am a title1', $result->items[1]['title']);
  $this
    ->assertEqual('I am a description1', $result->items[1]['description']);
  $this
    ->assertEqual('I am a title2', $result->items[2]['title']);
  $this
    ->assertEqual('I am a description2', $result->items[2]['description']);
}