function ScaffoldUpgradeTest::replaceCodeInFile
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ScaffoldUpgradeTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Functional\ScaffoldUpgradeTest::replaceCodeInFile()
Replaces a code fragment in a file.
Parameters
string $path: Path of the file to modify.
string $search: The code fragment to replace.
string $replace: The replacement code fragment.
File
-
core/
tests/ Drupal/ Tests/ Composer/ Plugin/ Scaffold/ Functional/ ScaffoldUpgradeTest.php, line 214
Class
- ScaffoldUpgradeTest
- Tests Upgrading the Composer Scaffold plugin.
Namespace
Drupal\Tests\Composer\Plugin\Scaffold\FunctionalCode
protected function replaceCodeInFile(string $path, string $search, string $replace) : void {
$contents = file_get_contents($path);
$this->assertStringContainsString($search, $contents, "Expected code not found in {$path}; update this test to match the current code.");
file_put_contents($path, str_replace($search, $replace, $contents));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.