function VendorHardeningPluginTest::testCleanPackage

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest::testCleanPackage()
  2. 8.9.x core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest::testCleanPackage()
  3. 11.x 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 47

Class

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

Namespace

Drupal\Tests\Composer\Plugin\VendorHardening

Code

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

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