Skip to content

Commit

Permalink
Adds a test for a missing VERSION file. (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius authored Apr 4, 2020
1 parent 99d749b commit 7f03fa2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
InputInterface $input = null,
OutputInterface $output = null
) {
if ($file = file_get_contents(dirname(dirname(__DIR__)) . '/VERSION')) {
if ($file = @file_get_contents(dirname(dirname(__DIR__)) . '/VERSION')) {
$version = trim($file);
} else {
throw new \Exception('No VERSION file');
Expand Down
22 changes: 20 additions & 2 deletions tests/AcquiaCliApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,29 @@ public function testConfig()

public function testVersion()
{
$command = ['--version'];
$versionFile = sprintf('%s/VERSION', $this->root);
$version = file_get_contents($versionFile);

$command = ['--version'];
$actualValue = $this->execute($command);

$this->assertContains('AcquiaCli 2', $actualValue);
$this->assertEquals(sprintf('AcquiaCli %s', $version), $actualValue);
}

public function testMissingVersion()
{
$versionFile = sprintf('%s/VERSION', $this->root);
$versionFileBak = sprintf('%s.bak', $versionFile);
$fileMoved = rename($versionFile, $versionFileBak);

try {
$command = ['--version'];
$this->execute($command);
} catch (\Exception $e) {
$this->assertEquals('Exception', get_class($e));
$this->assertEquals('No VERSION file', $e->getMessage());
}
rename($versionFileBak, $versionFile);
}

public function testLock()
Expand Down

0 comments on commit 7f03fa2

Please sign in to comment.