class FinderTest
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/DefaultContent/FinderTest.php \Drupal\Tests\Core\DefaultContent\FinderTest
@covers \Drupal\Core\DefaultContent\Finder @group DefaultContent
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait
- class \Drupal\Tests\Core\DefaultContent\FinderTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of FinderTest
File
-
core/
tests/ Drupal/ Tests/ Core/ DefaultContent/ FinderTest.php, line 16
Namespace
Drupal\Tests\Core\DefaultContentView source
class FinderTest extends UnitTestCase {
/**
* Tests that any discovered entity data is sorted into dependency order.
*/
public function testFoundDataIsInDependencyOrder() : void {
$finder = new Finder(__DIR__ . '/../../../../fixtures/default_content');
$expected_order = [
// First is the author of the node.
'94503467-be7f-406c-9795-fc25baa22203',
// Next, the taxonomy term referenced by the node.
'550f86ad-aa11-4047-953f-636d42889f85',
// Then we have the node itself, since it has no other dependencies.
'e1714f23-70c0-4493-8e92-af1901771921',
// Finally, the menu link to the node.
'3434bd5a-d2cd-4f26-bf79-a7f6b951a21b',
];
$this->assertSame($expected_order, array_slice(array_keys($finder->data), 0, 4));
}
/**
* Tests that files without UUIDs will raise an exception.
*/
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);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |
ExpectDeprecationTrait::getCallableName | private static | function | Returns a callable as a string suitable for inclusion in a message. | |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |
FinderTest::testExceptionIfNoUuid | public | function | Tests that files without UUIDs will raise an exception. | |
FinderTest::testFoundDataIsInDependencyOrder | public | function | Tests that any discovered entity data is sorted into dependency order. | |
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::$root | protected | property | The app root. | |
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::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |
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::setUp | protected | function | 358 | |
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.