public function VendorHardeningPluginTest::testWriteAccessRestrictionFiles in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest::testWriteAccessRestrictionFiles()
- 10 core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php \Drupal\Tests\Composer\Plugin\VendorHardening\VendorHardeningPluginTest::testWriteAccessRestrictionFiles()
@covers ::writeAccessRestrictionFiles
File
- core/
tests/ Drupal/ Tests/ Composer/ Plugin/ VendorHardening/ VendorHardeningPluginTest.php, line 150
Class
- VendorHardeningPluginTest
- @coversDefaultClass \Drupal\Composer\Plugin\VendorHardening\VendorHardeningPlugin @group VendorHardening
Namespace
Drupal\Tests\Composer\Plugin\VendorHardeningCode
public function testWriteAccessRestrictionFiles() {
$dir = vfsStream::url('vendor');
// Set up mocks so that writeAccessRestrictionFiles() can eventually use
// the IOInterface object.
$composer = $this
->getMockBuilder(Composer::class)
->setMethods([
'getPackage',
])
->getMock();
$composer
->expects($this
->once())
->method('getPackage')
->willReturn($this
->prophesize(RootPackageInterface::class)
->reveal());
$plugin = new VendorHardeningPlugin();
$plugin
->activate($composer, $this
->prophesize(IOInterface::class)
->reveal());
$this
->assertDirectoryExists($dir);
$this
->assertFileDoesNotExist($dir . '/.htaccess');
$this
->assertFileDoesNotExist($dir . '/web.config');
$plugin
->writeAccessRestrictionFiles($dir);
$this
->assertFileExists($dir . '/.htaccess');
$this
->assertFileExists($dir . '/web.config');
}