You are here

public function JsonPathParserTest::_testInvalidJsonLogMessages in Feeds extensible parsers 8

Tests log messages when using invalid JSON.

@todo Feeds log is gone.

File

tests/src/Unit/Feeds/Parser/JsonPathParserTest.php, line 168

Class

JsonPathParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\JsonPathParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function _testInvalidJsonLogMessages() {
  $config = [
    'context' => [
      'value' => '$.items[asdfasdf]',
    ],
  ] + $this->parser
    ->defaultConfiguration();
  $this->parser
    ->setConfiguration($config);
  try {
    $this->parser
      ->parse($this->feed, new RawFetcherResult('invalid json', $this->fileSystem), $this->state);
  } catch (Exception $e) {

    // Ignore any exceptions.
  }
  $log_messages = $this->feed
    ->getLogMessages();
  $this
    ->assertCount(1, $log_messages);
  $this
    ->assertSame($log_messages[0]['message'], 'Syntax error');
  $this
    ->assertSame($log_messages[0]['type'], 'feeds_ex');
  $this
    ->assertSame($log_messages[0]['severity'], 3);
}