Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Command/Push/PushArtifactCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,13 @@ private function scaffoldFiles(string $artifactDir): array
}
}
$this->scaffoldFiles[] = 'docroot/autoload.php';
// autoload_runtime.php was introduced in Drupal 11.4 as the Symfony
// Runtime bootstrap entry point. It is not in core's file-mapping so
// it must be force-added like autoload.php, but only when present —
// Drupal < 11.4 does not generate this file.
if (file_exists(Path::join($artifactDir, 'docroot', 'autoload_runtime.php'))) {
Comment on lines +460 to +464
$this->scaffoldFiles[] = 'docroot/autoload_runtime.php';
}

return $this->scaffoldFiles;
}
Expand Down
46 changes: 43 additions & 3 deletions tests/phpunit/src/Commands/Push/PushArtifactCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,30 @@ public function testPushArtifactNoPush(): void
$this->assertStringNotContainsString('Pushing changes to Acquia Git (site@svn-3.hosted.acquia-sites.com:site.git)', $output);
}

public function testPushArtifactWithoutAutoloadRuntime(): void
{
$applications = $this->mockRequest('getApplications');
$this->mockRequest('getApplicationByUuid', $applications[0]->uuid);
$environments = $this->mockRequest('getApplicationEnvironments', $applications[0]->uuid);
$localMachineHelper = $this->mockLocalMachineHelper();
$this->setUpPushArtifact($localMachineHelper, $environments[0]->vcs->path, [$environments[0]->vcs->url], 'master:master', true, true, false, true, false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setUpPushArtifact() call in the new test has 9 positional args, 5 of them booleans. It's unreadable:
can we do it this way

$this->setUpPushArtifact(
    localMachineHelper: $localMachineHelper,
    vcsPath: $environments[0]->vcs->path,
    vcsUrls: [$environments[0]->vcs->url],
    destGitRef: 'master:master',
    push: false,
    hasAutoloadRuntime: false,
);

$inputs = [
// Would you like Acquia CLI to search for a Cloud application that matches your local git config?
'n',
// Select a Cloud Platform application:
0,
// Would you like to link the project at ... ?
'y',
// Choose an Acquia environment:
0,
];
$this->executeCommand(['--no-push' => true], $inputs);

$output = $this->getDisplay();

$this->assertStringContainsString('Adding and committing changed files', $output);
}

public function testPushArtifactNoCommit(): void
{
$applications = $this->mockRequest('getApplications');
Expand Down Expand Up @@ -243,7 +267,7 @@ public function testPushArtifactNoClone(): void
$this->assertStringNotContainsString('Adding and committing changed files', $output);
$this->assertStringNotContainsString('Pushing changes to Acquia Git (site@svn-3.hosted.acquia-sites.com:site.git)', $output);
}
protected function setUpPushArtifact(ObjectProphecy $localMachineHelper, string $vcsPath, array $vcsUrls, string $destGitRef = 'master:master', bool $clone = true, bool $commit = true, bool $push = true, bool $printOutput = true): void
protected function setUpPushArtifact(ObjectProphecy $localMachineHelper, string $vcsPath, array $vcsUrls, string $destGitRef = 'master:master', bool $clone = true, bool $commit = true, bool $push = true, bool $printOutput = true, bool $hasAutoloadRuntime = true): void
{
touch(Path::join($this->projectDir, 'composer.json'));
mkdir(Path::join($this->projectDir, 'docroot'));
Expand All @@ -267,7 +291,7 @@ protected function setUpPushArtifact(ObjectProphecy $localMachineHelper, string
$this->mockCloneShallow($localMachineHelper, $vcsPath, $vcsUrls[0], $artifactDir, $printOutput);
}
if ($commit) {
$this->mockGitAddCommit($localMachineHelper, $artifactDir, $commitHash, $printOutput);
$this->mockGitAddCommit($localMachineHelper, $artifactDir, $commitHash, $printOutput, $hasAutoloadRuntime);
}
if ($push) {
$this->mockGitPush($vcsUrls, $localMachineHelper, $artifactDir, $destGitRef, $printOutput);
Expand Down Expand Up @@ -340,7 +364,7 @@ protected function mockComposerInstall(ObjectProphecy $localMachineHelper, mixed
->willReturn($process->reveal())->shouldBeCalled();
}

protected function mockGitAddCommit(ObjectProphecy $localMachineHelper, string $artifactDir, string $commitHash, bool $printOutput): void
protected function mockGitAddCommit(ObjectProphecy $localMachineHelper, string $artifactDir, string $commitHash, bool $printOutput, bool $hasAutoloadRuntime = true): void
{
$process = $this->mockProcess();
$localMachineHelper->execute([
Expand All @@ -363,6 +387,22 @@ protected function mockGitAddCommit(ObjectProphecy $localMachineHelper, string $
'docroot/autoload.php',
], null, $artifactDir, false)
->willReturn($process->reveal())->shouldBeCalled();
$runtimeFile = Path::join($artifactDir, 'docroot', 'autoload_runtime.php');
if ($hasAutoloadRuntime) {
// Simulate Drupal 11.4+ where autoload_runtime.php is generated.
@mkdir(Path::join($artifactDir, 'docroot'), 0777, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do this

touch($runtimeFile);
$localMachineHelper->execute([
'git',
'add',
'-f',
'docroot/autoload_runtime.php',
], null, $artifactDir, false)
->willReturn($process->reveal())->shouldBeCalled();
} else {
// Simulate Drupal < 11.4 where autoload_runtime.php is absent.
@unlink($runtimeFile);
}
Comment on lines +402 to +405
$localMachineHelper->execute([
'git',
'add',
Expand Down
Loading