Newer
Older

Adam G-H
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Drupal\Tests\package_manager\Kernel\PathExcluder;
use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase;
/**
* @covers \Drupal\package_manager\PathExcluder\VendorHardeningExcluder
*
* @group package_manager
*/
class VendorHardeningExcluderTest extends PackageManagerKernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp(): void {
// In this test, we want to disable the lock file validator because, even
// though both the active and stage directories will have a valid lock file,
// this validator will complain because they don't differ at all.
$this->disableValidators[] = 'package_manager.validator.lock_file';
parent::setUp();
}
/**
* Tests that vendor hardening files are excluded from staging operations.
*/
public function testVendorHardeningFilesExcluded(): void {
// In this test, we want to perform the actual staging operations so that we
// can be sure that files are staged as expected.
$this->disableModules(['package_manager_bypass']);
// Ensure we have an up-to-date container.
$this->container = $this->container->get('kernel')->getContainer();
$this->createTestProject();
$active_dir = $this->container->get('package_manager.path_locator')
->getProjectRoot();
$stage = $this->createStage();
$stage->create();
$stage_dir = $stage->getStageDirectory();
$ignored = [
'vendor/.htaccess',
'vendor/web.config',
];
foreach ($ignored as $path) {
$this->assertFileExists("$active_dir/$path");
$this->assertFileDoesNotExist("$stage_dir/$path");
}
$stage->apply();
// The ignored files should still be in the active directory.
foreach ($ignored as $path) {
$this->assertFileExists("$active_dir/$path");
}
}
}