Platformsh\Cli\Tests\Toolstack\DrupalTest::testBuildDrupalInProjectMode PHP Method

testBuildDrupalInProjectMode() public method

    public function testBuildDrupalInProjectMode()
    {
        $sourceDir = 'tests/data/apps/drupal/project';
        $projectRoot = $this->createDummyProject($sourceDir);
        $webRoot = $projectRoot . '/' . self::$config->get('local.web_root');
        $shared = $projectRoot . '/' . self::$config->get('local.shared_dir');
        $buildDir = $projectRoot . '/' . self::$config->get('local.build_dir') . '/default';
        // Insert a dummy file into 'shared'.
        if (!file_exists($shared)) {
            mkdir($shared, 0755, true);
        }
        touch($shared . '/symlink_me');
        self::$output->writeln("\nTesting build for directory: " . $sourceDir);
        $buildSettings = ['abslinks' => true];
        $builder = new LocalBuild($buildSettings + $this->buildSettings, null, self::$output);
        $success = $builder->build($projectRoot);
        $this->assertTrue($success, 'Build success for dir: ' . $sourceDir);
        // Test build results.
        $this->assertFileExists($webRoot . '/index.php');
        // Test installation results: firstly, the mounts.
        $this->assertFileExists($webRoot . '/sites/default/files');
        $this->assertFileExists($buildDir . '/tmp');
        $this->assertFileExists($buildDir . '/private');
        $this->assertFileExists($buildDir . '/drush-backups');
        $this->assertEquals($shared . '/files', readlink($webRoot . '/sites/default/files'));
        $this->assertEquals($shared . '/tmp', readlink($buildDir . '/tmp'));
        $this->assertEquals($shared . '/private', readlink($buildDir . '/private'));
        $this->assertEquals($shared . '/drush-backups', readlink($buildDir . '/drush-backups'));
        // Secondly, the special Drupal settings files.
        $this->assertFileExists($webRoot . '/sites/default/settings.php');
        $this->assertFileExists($webRoot . '/sites/default/settings.local.php');
        // Thirdly, the ability for any files in 'shared' to be symlinked into
        // sites/default (this is a legacy feature of the CLI's Drupal
        // toolstack).
        $this->assertFileExists($webRoot . '/sites/default/symlink_me');
        // Test custom build hooks' results.
        // Build hooks are not Drupal-specific, but they can only run if the
        // build process creates a build directory outside the repository -
        // Drupal is the only current example of this.
        $this->assertFileNotExists($webRoot . '/robots.txt');
        $this->assertFileExists($webRoot . '/test.txt');
        // Test building the same project again.
        $success2 = $builder->build($projectRoot);
        $this->assertTrue($success2, 'Second build success for dir: ' . $sourceDir);
    }