function BuildTestTest::testCopyCodebaseExclude
Same name in other branches
- 9 core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php \Drupal\BuildTests\Framework\Tests\BuildTestTest::testCopyCodebaseExclude()
- 8.9.x core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php \Drupal\BuildTests\Framework\Tests\BuildTestTest::testCopyCodebaseExclude()
- 11.x core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php \Drupal\BuildTests\Framework\Tests\BuildTestTest::testCopyCodebaseExclude()
Ensure we're not copying directories we wish to exclude.
@covers ::copyCodebase
File
-
core/
tests/ Drupal/ BuildTests/ Framework/ Tests/ BuildTestTest.php, line 61
Class
- BuildTestTest
- @coversDefaultClass \Drupal\BuildTests\Framework\BuildTestBase @group Build
Namespace
Drupal\BuildTests\Framework\TestsCode
public function testCopyCodebaseExclude() : void {
// Create a virtual file system containing items that should be
// excluded. Exception being modules directory.
vfsStream::setup('drupal', NULL, [
'sites' => [
'default' => [
'files' => [
'a_file.txt' => 'some file.',
],
'settings.php' => '<?php $settings = stuff;',
'settings.local.php' => '<?php $settings = override;',
],
'simpletest' => [
'simpletest_hash' => [
'some_results.xml' => '<xml/>',
],
],
],
'modules' => [
'my_module' => [
'vendor' => [
'my_vendor' => [
'composer.json' => "{\n}",
],
],
],
],
]);
// Mock BuildTestBase so that it thinks our VFS is the Composer and Drupal
// roots.
/** @var \PHPUnit\Framework\MockObject\MockBuilder|\Drupal\BuildTests\Framework\BuildTestBase $base */
$base = $this->getMockBuilder(BuildTestBase::class)
->onlyMethods([
'getDrupalRoot',
'getComposerRoot',
])
->getMockForAbstractClass();
$base->expects($this->exactly(1))
->method('getDrupalRoot')
->willReturn(vfsStream::url('drupal'));
$base->expects($this->exactly(3))
->method('getComposerRoot')
->willReturn(vfsStream::url('drupal'));
$base->setUp();
// Perform the copy.
$test_directory = 'copied_codebase';
$base->copyCodebase(NULL, $test_directory);
$full_path = $base->getWorkspaceDirectory() . '/' . $test_directory;
$this->assertDirectoryExists($full_path);
// Verify nested vendor directory was not excluded. Then remove it for next
// validation.
$this->assertFileExists($full_path . DIRECTORY_SEPARATOR . 'modules/my_module/vendor/my_vendor/composer.json');
$file_system = new Filesystem();
$file_system->remove($full_path . DIRECTORY_SEPARATOR . 'modules');
// Use scandir() to determine if our target directory is empty. It should
// only contain the system dot directories.
$this->assertTrue(($files = @scandir($full_path)) && count($files) <= 2, 'Directory is not empty: ' . implode(', ', $files));
$base->tearDown();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.