You are here

class ReplaceOpTest in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Integration/ReplaceOpTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Integration\ReplaceOpTest
  2. 10 core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Integration/ReplaceOpTest.php \Drupal\Tests\Composer\Plugin\Scaffold\Integration\ReplaceOpTest

@coversDefaultClass \Drupal\Composer\Plugin\Scaffold\Operations\ReplaceOp

@group Scaffold

Hierarchy

Expanded class hierarchy of ReplaceOpTest

File

core/tests/Drupal/Tests/Composer/Plugin/Scaffold/Integration/ReplaceOpTest.php, line 16

Namespace

Drupal\Tests\Composer\Plugin\Scaffold\Integration
View source
class ReplaceOpTest extends TestCase {
  use PhpunitCompatibilityTrait;

  /**
   * @covers ::process
   */
  public function testProcess() {
    $fixtures = new Fixtures();
    $destination = $fixtures
      ->destinationPath('[web-root]/robots.txt');
    $source = $fixtures
      ->sourcePath('drupal-assets-fixture', 'robots.txt');
    $options = ScaffoldOptions::create([]);
    $sut = new ReplaceOp($source, TRUE);

    // Assert that there is no target file before we run our test.
    $this
      ->assertFileNotExists($destination
      ->fullPath());

    // Test the system under test.
    $sut
      ->process($destination, $fixtures
      ->io(), $options);

    // Assert that the target file was created.
    $this
      ->assertFileExists($destination
      ->fullPath());

    // Assert the target contained the contents from the correct scaffold file.
    $contents = trim(file_get_contents($destination
      ->fullPath()));
    $this
      ->assertEquals('# Test version of robots.txt from drupal/core.', $contents);

    // Confirm that expected output was written to our io fixture.
    $output = $fixtures
      ->getOutput();
    $this
      ->assertStringContainsString('Copy [web-root]/robots.txt from assets/robots.txt', $output);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
ReplaceOpTest::testProcess public function @covers ::process