2017-03-16 20:03:11 +07:00
|
|
|
<?php
|
|
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Deployer;
|
|
|
|
|
2017-03-19 18:15:02 +07:00
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
2017-03-16 20:54:09 +07:00
|
|
|
class DeployTest extends DepCase
|
2017-03-16 20:03:11 +07:00
|
|
|
{
|
|
|
|
protected function load()
|
|
|
|
{
|
2017-03-21 15:26:09 +07:00
|
|
|
require FIXTURES . '/recipe/deploy.php';
|
2017-03-16 20:03:11 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDeploy()
|
|
|
|
{
|
2017-03-19 18:15:02 +07:00
|
|
|
$output = $this->start('deploy', ['localhost'], ['verbosity' => OutputInterface::VERBOSITY_DEBUG]);
|
2017-03-16 20:03:11 +07:00
|
|
|
self::assertContains('Successfully deployed!', $output);
|
|
|
|
self::assertDirectoryExists(self::$deployPath . '/.dep');
|
|
|
|
self::assertDirectoryExists(self::$deployPath . '/releases');
|
|
|
|
self::assertDirectoryExists(self::$deployPath . '/shared');
|
|
|
|
self::assertDirectoryExists(self::$deployPath . '/current');
|
|
|
|
self::assertFileExists(self::$deployPath . '/current/composer.json');
|
|
|
|
self::assertEquals(1, exec("ls -1 releases | wc -l"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testKeepReleases()
|
|
|
|
{
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
exec('touch current/ok.txt');
|
|
|
|
|
|
|
|
$this->start('deploy', ['localhost']);
|
|
|
|
exec('touch current/fail.txt');
|
|
|
|
|
|
|
|
self::assertEquals(5, exec("ls -1 releases | wc -l"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testKeepReleases
|
|
|
|
*/
|
|
|
|
public function testRollback()
|
|
|
|
{
|
|
|
|
$this->start('rollback', ['localhost']);
|
|
|
|
|
|
|
|
self::assertEquals(4, exec("ls -1 releases | wc -l"));
|
|
|
|
self::assertFileExists(self::$deployPath . '/current/ok.txt');
|
|
|
|
self::assertFileNotExists(self::$deployPath . '/current/fail.txt');
|
|
|
|
}
|
|
|
|
}
|