function FinderTest::testExceptionIfNoUuid

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php \Drupal\Tests\Core\DefaultContent\FinderTest::testExceptionIfNoUuid()

Tests that files without UUIDs will raise an exception.

File

core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php, line 40

Class

FinderTest
@covers <a href="/api/drupal/core%21lib%21Drupal%21Core%21DefaultContent%21Finder.php/class/Finder/11.x" title="Finds all default content in a directory, in dependency order." class="local">\Drupal\Core\DefaultContent\Finder</a> @group DefaultContent

Namespace

Drupal\Tests\Core\DefaultContent

Code

public function testExceptionIfNoUuid() : void {
    $dir = FileSystem::getOsTemporaryDirectory();
    $this->assertIsString($dir);
    
    /** @var string $dir */
    file_put_contents($dir . '/no-uuid.yml', '_meta: {}');
    $this->expectException(ImportException::class);
    $this->expectExceptionMessage("{$dir}/no-uuid.yml does not have a UUID.");
    new Finder($dir);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.