class YamlDiscoveryTest

Same name in this branch
  1. main core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryTest
  2. main core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest
Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest
  2. 11.x core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryTest
  3. 11.x core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest
  4. 10 core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest
  5. 10 core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryTest
  6. 10 core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest
  7. 9 core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest
  8. 9 core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryTest
  9. 9 core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest
  10. 8.9.x core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Discovery\YamlDiscoveryTest
  11. 8.9.x core/tests/Drupal/Tests/Core/Plugin/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Core\Plugin\Discovery\YamlDiscoveryTest
  12. 8.9.x core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php \Drupal\Tests\Component\Discovery\YamlDiscoveryTest

YamlDiscovery component unit tests.

Attributes

#[Group('Discovery')]

Hierarchy

Expanded class hierarchy of YamlDiscoveryTest

File

core/tests/Drupal/Tests/Core/Discovery/YamlDiscoveryTest.php, line 19

Namespace

Drupal\Tests\Core\Discovery
View source
class YamlDiscoveryTest extends UnitTestCase {
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    // Ensure that FileCacheFactory has a prefix.
    FileCacheFactory::setPrefix('prefix');
  }
  
  /**
   * Tests if filename is output for a broken YAML file.
   */
  public function testFilenameForBrokenYml() : void {
    vfsStreamWrapper::register();
    $root = new vfsStreamDirectory('modules');
    vfsStreamWrapper::setRoot($root);
    $url = vfsStream::url('modules');
    mkdir($url . '/test_broken');
    file_put_contents($url . '/test_broken/test_broken.test.yml', "broken:\n:");
    $this->expectException(InvalidDataTypeException::class);
    $this->expectExceptionMessageIs('vfs://modules/test_broken/test_broken.test.yml: Unable to parse at line 2 (near ":").');
    $directories = [
      'test_broken' => $url . '/test_broken',
    ];
    $discovery = new YamlDiscovery('test', $directories);
    $discovery->findAll();
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title Overrides
DrupalTestCase::$root protected property The Drupal root directory.
DrupalTestCase::getDrupalRoot Deprecated protected function Returns the Drupal root directory. 1
DrupalTestCase::setUpRoot final protected function Ensure that the $root property is set initially.
DrupalTestCase::skipTestWithAttribute final protected function Supports skipping tests with the Skip attribute.
DrupalTestCaseTrait::checkErrorHandlerOnTearDown public function Checks the test error handler after test execution. 1
DrupalTestCaseTrait::checkLegacySymfonyDeprecationHelperEnvVariable public function Checks legacy SYMFONY_DEPRECATIONS_HELPER env variable is not used.
DrupalTestCaseTrait::expectExceptionMessageIs protected function Expects an exactly matching exception message.
DrupalTestCaseTrait::expectExceptionMessageIsOrContains protected function Expects an exception message containing a specified string.
DrupalTestCaseTrait::setDebugDumpHandler public static function Registers the dumper CLI handler when the DebugDump extension is enabled.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setupMockIterator protected function Set up a traversable class mock to return specific items when iterated.
YamlDiscoveryTest::setUp protected function Overrides UnitTestCase::setUp
YamlDiscoveryTest::testFilenameForBrokenYml public function Tests if filename is output for a broken YAML file.

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