diff --git a/.travis.yml b/.travis.yml index 98456efc6..01a859a4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,10 @@ jobs: - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } + - { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS } - { name: "Custom job", env: ORCA_JOB=CUSTOM ORCA_CUSTOM_FIXTURE_INIT_ARGS="--help" ORCA_CUSTOM_TESTS_RUN_ARGS="--help" } + allow_failures: + - { php: "7.3", env: ORCA_JOB=D9_READINESS } before_install: - ../orca/bin/travis/self-test/before_install.sh diff --git a/bin/travis/install.sh b/bin/travis/install.sh index 8b7531b2b..6eaeee104 100755 --- a/bin/travis/install.sh +++ b/bin/travis/install.sh @@ -22,5 +22,6 @@ case "$ORCA_JOB" in "ISOLATED_DEV") orca debug:packages CURRENT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --sut-only --core=CURRENT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;; "INTEGRATED_DEV") orca debug:packages CURRENT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --core=CURRENT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;; "CORE_NEXT") orca debug:packages NEXT_DEV; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --core=NEXT_DEV --dev --profile=$ORCA_FIXTURE_PROFILE" ;; + "D9_READINESS") orca debug:packages D9_READINESS; eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --sut-only --core='~9' --dev --profile=$ORCA_FIXTURE_PROFILE" ;; "CUSTOM") eval "orca fixture:init -f --sut=$ORCA_SUT_NAME --profile=$ORCA_FIXTURE_PROFILE ${ORCA_CUSTOM_FIXTURE_INIT_ARGS:=}" ;; esac diff --git a/example/.travis.yml b/example/.travis.yml index 7a994b7b6..2505cbc7e 100644 --- a/example/.travis.yml +++ b/example/.travis.yml @@ -97,6 +97,7 @@ jobs: - { name: "Isolated test w/ dev package versions", env: ORCA_JOB=ISOLATED_DEV } - { name: "Integrated test w/ dev package versions", env: ORCA_JOB=INTEGRATED_DEV } - { name: "Integrated test w/ dev package versions & next minor dev version of Drupal core", env: ORCA_JOB=CORE_NEXT } + - { name: "D9 readiness test", php: "7.3", env: ORCA_JOB=D9_READINESS} # Custom testing needs involving only minor variations on the standard setup # can be achieved without custom scripting using the "CUSTOM" ORCA_JOB. # @see https://github.com/acquia/orca/blob/master/docs/advanced-usage.md#travis-ci-scripts @@ -109,6 +110,8 @@ jobs: - env: ORCA_JOB=ISOLATED_DEV - env: ORCA_JOB=INTEGRATED_DEV - env: ORCA_JOB=CORE_NEXT + # You may need to allow the D9 readiness job to fail in the short term. + - { php: "7.3", env: ORCA_JOB=D9_READINESS } # Install ORCA and prepare the environment. before_install: diff --git a/example/example.info.yml b/example/example.info.yml index ebe0bf802..7514f12ea 100644 --- a/example/example.info.yml +++ b/example/example.info.yml @@ -3,3 +3,4 @@ type: module description: "Provides an example module for testing and illustration purposes." package: Other core: 8.x +core_version_requirement: '^8 || ^9' diff --git a/src/Command/Debug/DebugPackagesCommand.php b/src/Command/Debug/DebugPackagesCommand.php index a4b8eb29a..29ce2bfba 100644 --- a/src/Command/Debug/DebugPackagesCommand.php +++ b/src/Command/Debug/DebugPackagesCommand.php @@ -105,6 +105,7 @@ public function execute(InputInterface $input, OutputInterface $output): int { } (new Table($output)) + ->setHeaderTitle("Drupal {$this->coreVersion}") ->setHeaders($this->getHeaders()) ->setRows($this->getRows()) ->render(); @@ -120,8 +121,8 @@ public function execute(InputInterface $input, OutputInterface $output): int { * @SuppressWarnings(PHPMD.StaticAccess) */ private function handleCoreArgument($argument): void { - if (is_null($argument)) { - return; + if ($argument === NULL) { + $argument = '*'; } if (!is_string($argument)) { diff --git a/src/Enum/DrupalCoreVersion.php b/src/Enum/DrupalCoreVersion.php index 97a64aebb..083572ef4 100644 --- a/src/Enum/DrupalCoreVersion.php +++ b/src/Enum/DrupalCoreVersion.php @@ -21,6 +21,8 @@ final class DrupalCoreVersion extends Enum { public const NEXT_DEV = 'NEXT_DEV'; + public const D9_READINESS = 'D9_READINESS'; + /** * Provides help text for commands that accept Drupal core version input. * @@ -35,6 +37,7 @@ public static function commandHelp() { sprintf('- %s: The current development version, e.g., "8.6.x-dev"', self::CURRENT_DEV), sprintf('- %s: The next release version if available, e.g., "8.7.0-beta2"', self::NEXT_RELEASE), sprintf('- %s: The next development version, e.g., "8.7.x-dev"', self::NEXT_DEV), + sprintf('- %s: The current development version of Drupal 9, e.g., "9.0.x-dev"', self::D9_READINESS), ]; } diff --git a/src/Utility/DrupalCoreVersionFinder.php b/src/Utility/DrupalCoreVersionFinder.php index ab445667a..eea3cc52b 100644 --- a/src/Utility/DrupalCoreVersionFinder.php +++ b/src/Utility/DrupalCoreVersionFinder.php @@ -66,6 +66,9 @@ public function get(DrupalCoreVersion $version): string { case DrupalCoreVersion::NEXT_DEV: return $this->getNextDevVersion(); + case DrupalCoreVersion::D9_READINESS: + return $this->getD9DevVersion(); + default: throw new \LogicException(sprintf('Unknown version. Update %s:%s.', __CLASS__, __FUNCTION__)); } @@ -97,17 +100,20 @@ public function getPretty(DrupalCoreVersion $version): string { * @param string $minimum_stability * The minimum stability. Available options (in order of stability) are * dev, alpha, beta, RC, and stable. + * @param string $preferred_stability + * The preferred stability. Available options (in order of stability) are + * dev, alpha, beta, RC, and stable. * * @return string * The version string. */ - public function find(string $target_package_version = NULL, string $minimum_stability = 'stable'): string { + public function find(string $target_package_version = NULL, string $minimum_stability = 'stable', string $preferred_stability = 'stable'): string { $best_candidate = $this->getVersionSelector($minimum_stability) - ->findBestCandidate('drupal/core', $target_package_version); + ->findBestCandidate('drupal/core', $target_package_version, NULL, $preferred_stability); if (!$best_candidate) { throw new \RuntimeException(sprintf('No Drupal core version satisfies the given constraints: version=%s, minimum stability=%s', $target_package_version, $minimum_stability)); } - return $best_candidate->getVersion(); + return $best_candidate->getPrettyVersion(); } /** @@ -196,6 +202,18 @@ private function getNextDevVersion(): string { return "{$previous_minor_version}.x-dev"; } + /** + * Gets the next D9 dev version. + * + * @return string + * The version string, e.g., "9.0.x-dev". + * + * @see \Acquia\Orca\Enum\DrupalCoreVersion::D9_READINESS + */ + private function getD9DevVersion(): string { + return $this->find('~9', 'dev', 'dev'); + } + /** * Gets a Composer version selector. * diff --git a/tests/Command/Debug/DebugPackagesCommandTest.php b/tests/Command/Debug/DebugPackagesCommandTest.php index f2b660574..00bb1dd7a 100644 --- a/tests/Command/Debug/DebugPackagesCommandTest.php +++ b/tests/Command/Debug/DebugPackagesCommandTest.php @@ -10,7 +10,6 @@ use Acquia\Orca\Tests\Command\CommandTestBase; use Acquia\Orca\Utility\DrupalCoreVersionFinder; use Composer\Semver\VersionParser; -use Prophecy\Argument; use Symfony\Component\Console\Command\Command; /** @@ -43,8 +42,8 @@ public function testBasicExecution() { $package->getType()->willReturn('drupal-module'); $package->getInstallPathRelative()->willReturn('docroot/modules/contrib/example1', 'docroot/modules/contrib/example2'); $package->getRepositoryUrlRaw()->willReturn('../example1', '../example2'); - $package->getVersionRecommended(NULL)->willReturn('~1.0'); - $package->getVersionDev(NULL)->willReturn('1.x-dev'); + $package->getVersionRecommended('*')->willReturn('~1.0'); + $package->getVersionDev('*')->willReturn('1.x-dev'); $package->shouldGetEnabled()->willReturn(TRUE); $this->packageManager ->getAll() @@ -53,14 +52,14 @@ public function testBasicExecution() { $this->executeCommand(); - $this->assertEquals(ltrim(" -+-----------+---------------+----------------------------------+-------------+---------+-------------+--------+ + $this->assertEquals(ltrim(' ++-----------+---------------+--------------------- Drupal * ---+-------------+---------+-------------+--------+ | Package | type | install_path | url | version | version_dev | enable | +-----------+---------------+----------------------------------+-------------+---------+-------------+--------+ | Example 1 | drupal-module | docroot/modules/contrib/example1 | ../example1 | ~1.0 | 1.x-dev | yes | | Example 2 | drupal-module | docroot/modules/contrib/example2 | ../example2 | ~1.0 | 1.x-dev | yes | +-----------+---------------+----------------------------------+-------------+---------+-------------+--------+ -"), $this->getDisplay(), 'Displayed correct output.'); +'), $this->getDisplay(), 'Displayed correct output.'); $this->assertEquals(StatusCode::OK, $this->getStatusCode(), 'Returned correct status code.'); } @@ -70,26 +69,13 @@ public function testBasicExecution() { public function testValidArguments($argument) { $version = '8.7.0.0'; $this->drupalCoreVersionFinder - ->get(Argument::any()) + ->get(new DrupalCoreVersion($argument)) ->shouldBeCalledOnce() ->willReturn($version); - $package = $this->prophesize(Package::class); - $package->getPackageName()->willReturn('Example 1'); - $package->getType()->willReturn('drupal-module'); - $package->getInstallPathRelative()->willReturn('docroot/modules/contrib/example1'); - $package->getRepositoryUrlRaw()->willReturn('../example1'); - $package->getVersionRecommended($version) - ->shouldBeCalledOnce(); - $package->getVersionDev($version) - ->shouldBeCalledOnce(); - $this->packageManager - ->getAll() - ->shouldBeCalledOnce() - ->willReturn([$package]); - $package->shouldGetEnabled()->willReturn(TRUE); $this->executeCommand(['core' => $argument]); + $this->assertContains(ltrim("- Drupal {$version} -"), $this->getDisplay(), 'Displayed correct output.'); $this->assertEquals(StatusCode::OK, $this->getStatusCode(), 'Returned correct status code.'); } @@ -108,7 +94,7 @@ public function testInvalidArguments($version) { $this->executeCommand(['core' => $version]); $error_message = sprintf('Error: Invalid value for "core" option: "%s".', $version) . PHP_EOL - . 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", or any version string Composer understands.' . PHP_EOL; + . 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", "D9_READINESS", or any version string Composer understands.' . PHP_EOL; $this->assertEquals($error_message, $this->getDisplay(), 'Displayed correct output.'); $this->assertEquals(StatusCode::ERROR, $this->getStatusCode(), 'Returned correct status code.'); } diff --git a/tests/Command/Fixture/FixtureInitCommandTest.php b/tests/Command/Fixture/FixtureInitCommandTest.php index ec307afe2..121c37a5e 100644 --- a/tests/Command/Fixture/FixtureInitCommandTest.php +++ b/tests/Command/Fixture/FixtureInitCommandTest.php @@ -259,7 +259,7 @@ public function testCoreOptionVersionParsing($status_code, $value, $display) { public function providerCoreOptionVersionParsing() { $error_message = 'Error: Invalid value for "--core" option: "%s".' . PHP_EOL - . 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", or any version string Composer understands.' . PHP_EOL; + . 'Hint: Acceptable values are "PREVIOUS_RELEASE", "PREVIOUS_DEV", "CURRENT_RECOMMENDED", "CURRENT_DEV", "NEXT_RELEASE", "NEXT_DEV", "D9_READINESS", or any version string Composer understands.' . PHP_EOL; return [ [StatusCode::OK, self::CORE_VALUE_LITERAL_PREVIOUS_RELEASE, ''], [StatusCode::OK, self::CORE_VALUE_LITERAL_CURRENT_RECOMMENDED, ''],