class PackageInstallDirectWriteTest

Tests installing packages with direct write mode enabled.

@internal

Attributes

#[Group('package_manager')] #[Group('#slow')]

Hierarchy

Expanded class hierarchy of PackageInstallDirectWriteTest

File

core/modules/package_manager/tests/src/Build/PackageInstallDirectWriteTest.php, line 14

Namespace

Drupal\Tests\package_manager\Build
View source
class PackageInstallDirectWriteTest extends TemplateProjectTestBase {
  
  /**
   * Tests installing packages in a stage directory.
   */
  public function testPackageInstall() : void {
    $this->createTestProject('RecommendedProject');
    $allow_direct_write = var_export(TRUE, TRUE);
    $this->writeSettings("\n\$settings['package_manager_allow_direct_write'] = {$allow_direct_write};");
    $this->setReleaseMetadata([
      'alpha' => __DIR__ . '/../../fixtures/release-history/alpha.1.1.0.xml',
    ]);
    $this->addRepository('alpha', $this->copyFixtureToTempDirectory(__DIR__ . '/../../fixtures/build_test_projects/alpha/1.0.0'));
    // Repository definitions affect the lock file hash, so update the hash to
    // ensure that Composer won't complain that the lock file is out of sync.
    $this->runComposer('composer update --lock', 'project');
    // Use the API endpoint to create a stage and install alpha 1.0.0.
    $this->makePackageManagerTestApiRequest('/package-manager-test-api', [
      'runtime' => [
        'drupal/alpha:1.0.0',
      ],
    ]);
    // Assert the module was installed.
    $this->assertFileEquals(__DIR__ . '/../../fixtures/build_test_projects/alpha/1.0.0/composer.json', $this->getWebRoot() . '/modules/contrib/alpha/composer.json');
    $this->assertRequestedChangesWereLogged([
      'Install drupal/alpha 1.0.0',
    ]);
    $this->assertAppliedChangesWereLogged([
      'Installed drupal/alpha 1.0.0',
    ]);
  }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
AssertPreconditionsTrait::assertNoFailureMarker private static function Asserts that there is no failure marker present.
AssertPreconditionsTrait::failIfUnmetPreConditions protected static function Asserts universal test preconditions before any setup is done.
AssertPreconditionsTrait::getProjectRoot private static function Returns the absolute path of the project root.
AssertPreconditionsTrait::setUpBeforeClass public static function Invokes the test preconditions assertion before the first test is run.
BuildTestBase::$commandProcess private property The most recent command process.
BuildTestBase::$destroyBuild protected property Default to destroying build artifacts after a test finishes.
BuildTestBase::$hostName private static property Our native host name, used by PHP when it starts up the server.
BuildTestBase::$hostPort private property Port that will be tested.
BuildTestBase::$mink private property The Mink session manager.
BuildTestBase::$phpFinder private property The PHP executable finder.
BuildTestBase::$portLocks private property A list of ports used by the test.
BuildTestBase::$serverDocroot private property The docroot for the server process.
BuildTestBase::$serverProcess private property The process that's running the HTTP server.
BuildTestBase::$workspaceDir private property The working directory where this test will manipulate files.
BuildTestBase::assertCommandExitCode public function Asserts that the last command returned the specified exit code.
BuildTestBase::assertCommandOutputContains public function Assert that text is present in the output of the most recent command.
BuildTestBase::assertCommandSuccessful public function Asserts that the last command ran without error.
BuildTestBase::assertDrupalVisit public function Helper function to assert that the last visit was a Drupal site.
BuildTestBase::assertErrorOutputContains public function Assert that text is present in the error output of the most recent command.
BuildTestBase::assertErrorOutputNotContains public function Assert text is not present in the error output of the most recent command.
BuildTestBase::checkPortIsAvailable protected function Checks whether a port is available.
BuildTestBase::executeCommand public function Run a command.
BuildTestBase::findAvailablePort protected function Discover an available port number.
BuildTestBase::getCodebaseFinder public function Get a default Finder object for a Drupal codebase.
BuildTestBase::getComposerRoot public function Gets the path to the Composer root directory.
BuildTestBase::getDrupalRoot public function Get the root path of this Drupal codebase.
BuildTestBase::getDrupalRootStatic public static function Get the root path of this Drupal codebase.
BuildTestBase::getMink public function Get the Mink instance.
BuildTestBase::getPortNumber protected function Get the port number for requests.
BuildTestBase::getWorkingPath protected function Get the working directory within the workspace, creating if necessary.
BuildTestBase::getWorkingPathDrupalRoot public function Gets the working path for Drupal core.
BuildTestBase::getWorkspaceDirectory public function Full path to the workspace where this test can build.
BuildTestBase::getWorkspaceDrupalRoot public function Gets the path to Drupal root in the workspace directory.
BuildTestBase::initMink protected function Set up the Mink session manager.
BuildTestBase::standUpServer protected function Makes a local test server using PHP's internal HTTP server.
BuildTestBase::stopServer protected function Stop the HTTP server, zero out all necessary variables.
FixtureUtilityTrait::copyFixtureFilesTo protected static function Mirrors a fixture directory to the given path.
FixtureUtilityTrait::renameGitDirectories private static function Renames _git directories to .git.
FixtureUtilityTrait::renameInfoYmlFiles protected static function Renames all files that end with .info.yml.hide.
PackageInstallDirectWriteTest::testPackageInstall public function Tests installing packages in a stage directory.
QuickStartTestBase::$adminPassword protected property Password of the admin account generated during install.
QuickStartTestBase::$adminUsername protected property User name of the admin account generated during install.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RequiresComposerTrait::requiresComposer public static function #[BeforeClass]
TemplateProjectTestBase::$metadataServer private property A secondary server instance, to serve XML metadata about available updates.
TemplateProjectTestBase::$serverErrorLog private property All output that the PHP web server logs to the error buffer.
TemplateProjectTestBase::$webRoot private property The web root of the test site, relative to the workspace directory.
TemplateProjectTestBase::addRepository protected function Adds a path repository to the test site.
TemplateProjectTestBase::assertAppliedChangesWereLogged protected function Asserts that changes applied during the stage life cycle were logged.
TemplateProjectTestBase::assertExpectedStageEventsFired protected function Asserts stage events were fired in a specific order.
TemplateProjectTestBase::assertRequestedChangesWereLogged protected function Asserts changes requested during the stage life cycle were logged.
TemplateProjectTestBase::copyCodebase public function Copy the current working codebase into a workspace. Overrides BuildTestBase::copyCodebase
TemplateProjectTestBase::copyFixtureToTempDirectory protected function Copies a fixture directory to a temporary directory and returns its path.
TemplateProjectTestBase::createTestProject protected function Creates a test project from a given template and installs Drupal.
TemplateProjectTestBase::createVendorRepository protected function Creates a Composer repository for all dependencies of the test project.
TemplateProjectTestBase::formLogin public function Helper that uses Drupal's user/login form to log in. Overrides QuickStartTestBase::formLogin
TemplateProjectTestBase::getWebRoot protected function Returns the full path to the test site's document root.
TemplateProjectTestBase::installModules protected function Installs modules in the UI.
TemplateProjectTestBase::installQuickStart public function Install a Drupal site using the quick start feature. Overrides QuickStartTestBase::installQuickStart
TemplateProjectTestBase::instantiateServer protected function Do the work of making a server process. Overrides BuildTestBase::instantiateServer
TemplateProjectTestBase::makePackageManagerTestApiRequest protected function Gets a /package-manager-test-api response.
TemplateProjectTestBase::MAX_EXECUTION_TIME protected constant The PHP web server's max_execution_time value.
TemplateProjectTestBase::providerTemplate public static function Data provider for tests which use all the core project templates.
TemplateProjectTestBase::runComposer protected function Runs a Composer command and returns its output.
TemplateProjectTestBase::setReleaseMetadata protected function Prepares the test site to serve an XML feed of available release metadata.
TemplateProjectTestBase::setUp protected function Overrides BuildTestBase::setUp
TemplateProjectTestBase::setUpstreamCoreVersion protected function Sets the version of Drupal core to which the test site will be updated.
TemplateProjectTestBase::tearDown protected function Invokes the test preconditions assertion after each test run. Overrides AssertPreconditionsTrait::tearDown
TemplateProjectTestBase::unboundCoreConstraints private static function Changes constraints for core packages to `*`.
TemplateProjectTestBase::visit public function Visit a URI on the HTTP server. Overrides BuildTestBase::visit
TemplateProjectTestBase::visitPackageManagerChangeLog private function Visits the 'admin/reports/dblog' and selects Package Manager's change log.
TemplateProjectTestBase::writeSettings protected function Appends PHP code to the test site's settings.php.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.