trait AssertUtilsTrait
Same name in other branches
- 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait
- 8.9.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait
- 11.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait
Convenience class for creating fixtures.
Hierarchy
- trait \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait uses \Drupal\Tests\Traits\PhpUnitWarnings
4 files declare their use of AssertUtilsTrait
- ComposerHookTest.php in core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ComposerHookTest.php - ManageGitIgnoreTest.php in core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ManageGitIgnoreTest.php - ScaffoldTest.php in core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ScaffoldTest.php - ScaffoldUpgradeTest.php in core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ScaffoldUpgradeTest.php
File
-
core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ AssertUtilsTrait.php, line 12
Namespace
Drupal\Tests\Composer\Plugin\ScaffoldView source
trait AssertUtilsTrait {
use PhpUnitWarnings;
/**
* Asserts that a given file exists and is/is not a symlink.
*
* @param string $path
* The path to check exists.
* @param bool $is_link
* Checks if the file should be a symlink or not.
* @param string $contents_contains
* Regex to check the file contents.
*/
protected function assertScaffoldedFile($path, $is_link, $contents_contains) {
$this->assertFileExists($path);
$contents = file_get_contents($path);
$this->assertStringContainsString($contents_contains, basename($path) . ': ' . $contents);
$this->assertSame($is_link, is_link($path));
}
/**
* Asserts that a file does not exist or exists and does not contain a value.
*
* @param string $path
* The path to check exists.
* @param string $contents_not_contains
* A string that is expected should NOT occur in the file contents.
*/
protected function assertScaffoldedFileDoesNotContain($path, $contents_not_contains) {
// If the file does not exist at all, we'll count that as a pass.
if (!file_exists($path)) {
return;
}
$contents = file_get_contents($path);
$this->assertStringNotContainsString($contents_not_contains, $contents, basename($path) . ' contains unexpected contents:');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AssertUtilsTrait::assertScaffoldedFile | protected | function | Asserts that a given file exists and is/is not a symlink. |
AssertUtilsTrait::assertScaffoldedFileDoesNotContain | protected | function | Asserts that a file does not exist or exists and does not contain a value. |
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. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.