You are here

public function ContentLoaderTest::testMissingContentFile in YAML Content 8

Tests behavior when a content file is unavailable.

File

tests/src/Unit/ContentLoader/ContentLoaderTest.php, line 47

Class

ContentLoaderTest
Test generic functionality of the ContentLoader class.

Namespace

Drupal\Tests\yaml_content\Unit\ContentLoader

Code

public function testMissingContentFile() {
  $test_file = 'missing.content.yml';

  // Confirm the file is not actually present.
  $this
    ->assertFalse($this->root
    ->hasChild('content/missing.content.yml'));

  // Prepare the path for the missing content file.
  $this->contentLoader
    ->setContentPath($this->root
    ->url());

  // Parse the test file expecting an error for the missing file.
  $this
    ->expectException(\PHPUnit\Framework\Error\Warning::class);
  $this->contentLoader
    ->parseContent($test_file);
}