/** * @param string $command * @param string $expectedUrl * @dataProvider getCases */ public function testBuildUrl($command, $expectedUrl) { $result = ProcessUtil::runOk($this->cmd($command)); $this->assertRegExp(";Execute [^\n]*/download.sh;", $result->getOutput()); $this->assertRegExp(";Execute [^\n]*/install.sh;", $result->getOutput()); $this->assertContains("- CMS_URL: {$expectedUrl}\n", $result->getOutput()); }
public function testEmptyWithExtraZipfile_bad() { try { ProcessUtil::runOk($this->cmd('civibuild create civibuild-test --force --type empty ' . ' --dl ' . escapeshellarg('foo/bar=' . __DIR__ . '/does-not-exist.zip'))); $this->fail("Expected download to fail with error"); } catch (\Civi\Civibuild\Exception\ProcessErrorException $e) { $result = $e->getProcess(); $this->assertEquals(94, $result->getExitCode()); $this->assertContains('Failed to determine if archive is local/remote or zip/tar', $result->getOutput()); $this->assertNotRegExp('; - CMS_ROOT: .*/build/civibuild-test;', $result->getOutput()); } }
/** * Create a test instance name Civibuild-test * (assumes no one will have created such an instance) */ public function testBasic() { $escapedDir = escapeshellarg(__DIR__ . ''); $options = '--prefix hydratest- --url-template ' . escapeshellarg('http://%SITE_NAME%.localhost'); ProcessUtil::runOk($this->cmd("civihydra destroy {$options}")); $result = ProcessUtil::runOk($this->cmd("civihydra create {$options} {$escapedDir}/dummy-tarballs/*")); $this->assertFilesRegex(array($this->getAbsPath('hydratest-backdrop', 'modules/civicrm/README.txt') => ';civicrm-core plus civicrm-backdrop@1.x;', $this->getAbsPath('hydratest-drupal', 'sites/all/modules/civicrm/README.txt') => ';civicrm-core plus civicrm-drupal@7.x;', $this->getAbsPath('hydratest-wp', 'wp-content/plugins/civicrm/README.txt') => ';civicrm-core plus civicrm-wordpress;')); $builds = array('hydratest-backdrop', 'hydratest-drupal', 'hydratest-wp'); foreach ($builds as $build) { $this->assertRegExp('; - CMS_ROOT: [^\\n]+/build/' . preg_quote($build, ';') . ';', $result->getOutput()); $this->assertRegExp('; - CIVI_DB_DSN: mysql://.*:.*@.*/.*;', $result->getOutput()); $configFile = $this->getPrjDir() . "/build/{$build}.sh"; $this->assertFileExists($configFile); $config = file_get_contents($configFile); $this->assertRegExp(';CMS_ROOT=[^\\n]+/build/' . preg_quote($build, ';') . ';', $config); $this->assertRegExp(';CIVI_DB_DSN=\\"?mysql://.*:.*@.*/.*\\"?;', $config); } }
/** * @param $command * @dataProvider getCommandsWhichSupportDefaultBuild */ public function testUseDefaultBuildName($command) { $result = ProcessUtil::runOk($this->cmd("civibuild create {$this->buildName} --type {$this->buildType}")); $this->assertRegExp("; - CMS_ROOT: [^\n]*/{$this->buildName};", $result->getOutput()); $this->assertRegExp('; - CIVI_DB_DSN: mysql://.*:.*@.*/.*;', $result->getOutput()); $this->assertTrue(file_exists($this->getAbsPath($this->buildName))); $this->assertTrue(file_exists($this->getAbsPath($this->buildName . '.sh'))); $buildDir = $this->getAbsPath($this->buildName); mkdir("{$buildDir}/subdir"); // Run the command three different ways, and see if the results are the same. $resultWithArg = ProcessUtil::runOk($this->cmd("civibuild {$command} {$this->buildName}")); $this->assertNotEmpty($resultWithArg->getOutput()); $resultInSubdir = ProcessUtil::runOk($this->cmd("civibuild {$command}")->setWorkingDirectory("{$buildDir}/subdir")); $this->assertContains("[[Detected SITE_NAME: {$this->buildName}]]\n", $resultInSubdir->getOutput()); $this->assertEquals($resultWithArg->getOutput(), str_replace("[[Detected SITE_NAME: {$this->buildName}]]\n", "", $resultInSubdir->getOutput())); // FIXME: Bug! // $resultInDir = ProcessUtil::runOk( // $this->cmd("civibuild $command")->setWorkingDirectory($buildDir) // ); // $this->assertContains("[[Detected SITE_NAME: {$this->buildName}]]\n", $resultInSubdir->getOutput()); // $this->assertEquals( // $resultWithArg->getOutput(), // str_replace("[[Detected SITE_NAME: {$this->buildName}]]\n", "", $resultInDir->getOutput()) // ); }