class SiteFilesExcluderTest
@covers \Drupal\package_manager\PathExcluder\SiteFilesExcluder @group package_manager @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\PathExcluder\SiteFilesExcluderTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of SiteFilesExcluderTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ PathExcluder/ SiteFilesExcluderTest.php, line 15
Namespace
Drupal\Tests\package_manager\Kernel\PathExcluderView source
class SiteFilesExcluderTest extends PackageManagerKernelTestBase {
/**
* Tests that public and private files are excluded from stage operations.
*/
public function testSiteFilesExcluded() : void {
// The private stream wrapper is only registered if this setting is set.
// @see \Drupal\Core\CoreServiceProvider::register()
$this->setSetting('file_private_path', 'private');
// In this test, we want to perform the actual stage operations so that we
// can be sure that files are staged as expected. This will also rebuild
// the container, enabling the private stream wrapper.
$this->setSetting('package_manager_bypass_composer_stager', FALSE);
// Ensure we have an up-to-date container.
$this->container = $this->container
->get('kernel')
->rebuildContainer();
$active_dir = $this->container
->get(PathLocator::class)
->getProjectRoot();
// Ensure that we are using directories within the fake site fixture for
// public and private files.
$this->setSetting('file_public_path', "sites/example.com/files");
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
$stage_dir = $stage->getStageDirectory();
$excluded = [
"sites/example.com/files/exclude.txt",
'private/exclude.txt',
];
foreach ($excluded as $path) {
$this->assertFileExists("{$active_dir}/{$path}");
$this->assertFileDoesNotExist("{$stage_dir}/{$path}");
}
$stage->apply();
// The excluded files should still be in the active directory.
foreach ($excluded as $path) {
$this->assertFileExists("{$active_dir}/{$path}");
}
}
/**
* Tests that invalid file settings do not cause errors.
*/
public function testInvalidFileSettings() : void {
$invalid_path = '/path/does/not/exist';
$this->assertFileDoesNotExist($invalid_path);
$this->setSetting('file_public_path', $invalid_path);
$this->setSetting('file_private_path', $invalid_path);
// Ensure we have an up-to-date container.
$this->container = $this->container
->get('kernel')
->rebuildContainer();
$this->assertStatusCheckResults([]);
$this->assertResults([]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.