You are here

public function VendorHardeningPluginTest::testCleanPackage in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest::testCleanPackage()

@covers ::cleanPackage

File

core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php, line 36

Class

VendorHardeningPluginTest
@coversDefaultClass \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin @group VendorHardening

Namespace

Drupal\Tests\Composer\Plugin\VendorHardening

Code

public function testCleanPackage() {
  $config = $this
    ->getMockBuilder(Config::class)
    ->disableOriginalConstructor()
    ->getMock();
  $config
    ->expects($this
    ->once())
    ->method('getPathsForPackage')
    ->willReturn([
    'tests',
  ]);
  $plugin = new VendorHardeningPlugin();
  $ref_config = new \ReflectionProperty($plugin, 'config');
  $ref_config
    ->setAccessible(TRUE);
  $ref_config
    ->setValue($plugin, $config);
  $io = $this
    ->prophesize(IOInterface::class);
  $ref_io = new \ReflectionProperty($plugin, 'io');
  $ref_io
    ->setAccessible(TRUE);
  $ref_io
    ->setValue($plugin, $io
    ->reveal());
  $this
    ->assertFileExists(vfsStream::url('vendor/drupal/package/tests/SomeTest.php'));
  $plugin
    ->cleanPackage(vfsStream::url('vendor'), 'drupal/package');
  $this
    ->assertFileNotExists(vfsStream::url('vendor/drupal/package/tests'));
}