function VendorHardeningPluginTest::testWriteAccessRestrictionFiles

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

Class

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

Namespace

Drupal\Tests\Composer\Plugin\VendorHardening

Code

public function testWriteAccessRestrictionFiles() : void {
    $dir = vfsStream::url('vendor');
    // Set up mocks so that writeAccessRestrictionFiles() can eventually use
    // the IOInterface object.
    $composer = $this->getMockBuilder(Composer::class)
        ->onlyMethods([
        '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');
}

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