function AssertUtilsTrait::assertScaffoldedFileDoesNotContain

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait::assertScaffoldedFileDoesNotContain()
  2. 10 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/AssertUtilsTrait.php \Drupal\Tests\Composer\Plugin\Scaffold\AssertUtilsTrait::assertScaffoldedFileDoesNotContain()
  3. 11.x 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
Test appending to an unmanaged file, and confirm it is not .gitignored.

File

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

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.