deployer/tests/e2e/AbstractE2ETest.php
Anton Medvedev 387b4c1d51
Update composer dependencies (#2453)
As well rename test dir to tests, as Pest does not support dir without s on the end.
Also, remove PHP requirement from composer.json as we already have check-in bin/dep and it's better to have the check only in one place (now they already out of sync).
2021-03-12 13:56:16 +03:00

56 lines
1.3 KiB
PHP

<?php declare(strict_types=1);
namespace e2e;
use Deployer\Deployer;
use Deployer\Exception\Exception;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\ApplicationTester;
abstract class AbstractE2ETest extends TestCase
{
/**
* @var ApplicationTester
*/
protected $tester;
/**
* @var Deployer
*/
protected $deployer;
public static function setUpBeforeClass(): void
{
self::cleanUp();
mkdir(__TEMP_DIR__);
}
public static function tearDownAfterClass(): void
{
self::cleanUp();
}
protected static function cleanUp(): void
{
if (is_dir(__TEMP_DIR__)) {
exec('rm -rf ' . __TEMP_DIR__);
}
}
/**
* @param string $recipe path to recipe file
* @throws Exception
*/
protected function init(string $recipe): void
{
$console = new Application();
$console->setAutoExit(false);
$this->tester = new ApplicationTester($console);
$this->deployer = new Deployer($console);
$this->deployer->importer->import($recipe);
$this->deployer->init();
$this->deployer->config->set('deploy_path', __TEMP_DIR__ . '/{{hostname}}');
}
}