You are here

protected function AssertUtilsTrait::assertScaffoldedFileDoesNotContain in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait::assertScaffoldedFileDoesNotContain()

Asserts that a file does not exist or exists and does not contain a value.

Parameters

string $path: The path to check exists.

string $contents_not_contains: A string that is expected should NOT occur in the file contents.

1 call to AssertUtilsTrait::assertScaffoldedFileDoesNotContain()
ManageGitIgnoreTest::testAppendToEmptySettingsIsUnmanaged in core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Functional/ManageGitIgnoreTest.php
Tests appending to an unmanaged file, and confirm it is not .gitignored.

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php, line 38

Class

AssertUtilsTrait
Convenience class for creating fixtures.

Namespace

Drupal\Tests\Composer\Plugin\Scaffold

Code

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:');
}