-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Start with a failing test, to show that we have correctly replicated the problem. * Convert symlinks in the archive to avoid failures in the PharData class. * Move test to its own file. * Remove extraneous test steps in "setup" method of ArchiveTest that are not doing anything not already covered in the archive dump test. * Remove unnecessary logic * Update src/Commands/core/ArchiveDumpCommands.php * Update tests/functional/ArchiveSymlinkTest.php * Update src/Commands/core/ArchiveDumpCommands.php --------- Co-authored-by: Greg Anderson <[email protected]> Co-authored-by: Moshe Weitzman <[email protected]>
- Loading branch information
1 parent
1cbb21f
commit d2f2c67
Showing
3 changed files
with
135 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Unish; | ||
|
||
use Drush\Commands\core\ArchiveDumpCommands; | ||
use Drush\Commands\core\ArchiveRestoreCommands; | ||
use Drush\Commands\core\StatusCommands; | ||
use PharData; | ||
use Symfony\Component\Filesystem\Path; | ||
use Unish\Utils\FSUtils; | ||
|
||
/** | ||
* @group slow | ||
* @group commands | ||
* @group archive | ||
*/ | ||
class ArchiveSymlinkTest extends CommandUnishTestCase | ||
{ | ||
use FSUtils; | ||
|
||
protected string $archivePath; | ||
protected array $archiveDumpOptions; | ||
protected string $linktarget; | ||
protected string $linkdestination; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->setUpDrupal(1, true); | ||
$this->archiveDumpOptions = [ | ||
'db' => null, | ||
'files' => null, | ||
'code' => null, | ||
'exclude-code-paths' => 'sut/sites/.+/settings.php,(?!sut|composer\.json|composer\.lock).*', | ||
]; | ||
|
||
$this->archivePath = Path::join($this->getSandbox(), 'archive.tar.gz'); | ||
|
||
$this->linktarget = Path::join($this->getSandbox(), 'symlinktest.txt'); | ||
$this->linkdestination = Path::join($this->webroot(), 'symlinkdest.txt'); | ||
|
||
file_put_contents($this->linktarget, "This is a symlink target file."); | ||
symlink($this->linktarget, $this->linkdestination); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
unlink($this->linktarget); | ||
unlink($this->linkdestination); | ||
} | ||
|
||
public function testArchiveDumpSymlinkReplaceCommand(): void | ||
{ | ||
// The symlinks written in setup would cause the PharData class to | ||
// fail if we did not replace them before archiving. | ||
// @see https://github.com/drush-ops/drush/pull/6030 | ||
$this->drush( | ||
ArchiveDumpCommands::DUMP, | ||
[], | ||
array_merge($this->archiveDumpOptions, [ | ||
'destination' => $this->archivePath, | ||
'overwrite' => null, | ||
]) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters