class TraitsTest
Tests for the traits defined in\Drupal\Tests\examples\Unit.
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\examples\Unit\TraitsTest uses \Drupal\Tests\examples\Unit\FilesTestTrait, \Drupal\Tests\examples\Unit\RetrieveConfigFilesTrait, \Drupal\Tests\examples\Unit\RetrieveRoutingFilesTrait implements \Drupal\Tests\UnitTestCase
Expanded class hierarchy of TraitsTest
File
-
tests/
src/ Unit/ TraitsTest.php, line 10
Namespace
Drupal\Tests\examples\UnitView source
class TraitsTest extends UnitTestCase {
use FilesTestTrait;
use RetrieveConfigFilesTrait;
use RetrieveRoutingFilesTrait;
/**
* Provides test data for testNoUuidInConfig().
*
* @return array
* The test data.
*/
public static function providerConfigFiles() : array {
$data = [];
$directory = self::projectPathname('tests/modules');
return self::retrieveFiles($directory, 'yml', self::configFilesCallback(...));
}
/**
* Provides test data for testRoutingFilesCallback().
*
* @return array
* The test data.
*/
public static function providerRoutingFiles() : array {
$data = [];
$directory = self::projectPathname('tests/modules');
return self::retrieveFiles($directory, 'yml', self::routingFilesCallback(...));
}
/**
* Tests that RetrieveConfigFilesTrait::configFilesCallback() works.
*
* @dataProvider providerConfigFilesFiles
*/
public function testConfigFilesCallback(string $filename, string $path, string $pathname) : void {
$this->assertNotEquals('example_no_config_files_test.yml', $filename, "{$filename} is not in the right directory ({$path}) and should have not been retrieved.");
}
/**
* Tests that RetrieveRoutingFilesTrait::routingFilesCallback() works.
*
* @dataProvider providerRoutingFiles
*/
public function testRoutingFilesCallback(string $filename, $path, $pathname) : void {
$this->assertNotEquals('examples_no_module_test.routing.yml', $filename, "{$filename} is not a routing file used by a module because {$path} does not contain any .info.yml file.");
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|---|
FilesTestTrait::projectPathname | protected static | function | Gets the absolute pathname for a project directory. | ||
FilesTestTrait::retrieveFiles | protected static | function | Retrieves files in a project directory. | ||
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | ||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | ||
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. | ||
RandomGeneratorTrait::randomStringValidate | Deprecated | public | function | Callback for random string validation. | |
RetrieveConfigFilesTrait::configFilesCallback | protected static | function | Callback to filter Drupal configuration files. | ||
RetrieveRoutingFilesTrait::routingFilesCallback | protected static | function | Callback to filter Drupal routing files. | ||
TraitsTest::providerConfigFiles | public static | function | Provides test data for testNoUuidInConfig(). | ||
TraitsTest::providerRoutingFiles | public static | function | Provides test data for testRoutingFilesCallback(). | ||
TraitsTest::testConfigFilesCallback | public | function | Tests that RetrieveConfigFilesTrait::configFilesCallback() works. | ||
TraitsTest::testRoutingFilesCallback | public | function | Tests that RetrieveRoutingFilesTrait::routingFilesCallback() works. | ||
UnitTestCase::$root | protected | property | The app root. | 1 | |
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 | |||
UnitTestCase::__get | public | function |