You are here

public function XmlParserTest::testValidateExpression in Feeds extensible parsers 8

Tests XPath validation.

File

tests/src/Unit/Feeds/Parser/XmlParserTest.php, line 259

Class

XmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\XmlParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testValidateExpression() {

  // Invalid expression.
  $expression = '!! ';
  $this
    ->assertSame('Invalid expression', (string) $this
    ->invokeMethod($this->parser, 'validateExpression', [
    &$expression,
  ]));

  // Test that value was trimmed.
  $this
    ->assertSame($expression, '!!', 'Value was trimmed.');

  // Unknown namespace.
  $unknown = 'thing:asdf';
  $this
    ->assertSame(NULL, $this
    ->invokeMethod($this->parser, 'validateExpression', [
    &$unknown,
  ]));

  // Empty.
  $empty = '';
  $this
    ->assertSame(NULL, $this
    ->invokeMethod($this->parser, 'validateExpression', [
    &$empty,
  ]));
}