Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"require": {
"php": "^8.0|^7.3",
"ext-json": "*",
"justinrainbow/json-schema": "^5.2",
"justinrainbow/json-schema": "6.0.0-beta",
"psr/http-message": "^1",
"react/http": "^1.5",
"symfony/console": "^5.4.9",
Expand Down
220 changes: 206 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 25 additions & 11 deletions tests/src/Importer/ImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@
namespace Deployer\Importer;

use Deployer\Deployer;
use Deployer\Exception\ConfigurationException;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Output\Output;

class ImporterTest extends TestCase
{
private $previousInput;
private $previousOutput;

public function setUp(): void
{
$deployer = Deployer::get();
$this->previousInput = $deployer->input;
$this->previousOutput = $deployer->output;
}
$console = new Application();
$input = $this->createMock(Input::class);
$output = $this->createMock(Output::class);

public function tearDown(): void
{
Deployer::get()->input = $this->previousInput;
Deployer::get()->output = $this->previousOutput;
$deployer = new Deployer($console);
$deployer->input = $input;
$deployer->output = $output;
}

public function testCanOneOverrideStaticMethod(): void
Expand Down Expand Up @@ -79,4 +78,19 @@ public function testImporterIgnoresYamlHiddenKeys(): void
self::assertEquals('foo', Deployer::get()->hosts->get('acceptance')->getRemoteUser());
self::assertEquals('bar', Deployer::get()->hosts->get('production')->getRemoteUser());
}

public function testThrowsForInvalidConfig(): void
{
$data = <<<EOL
unknownProperty: some-string-value
EOL;
$tmpFile = tempnam(sys_get_temp_dir(), 'deployer-') . '.yaml';
file_put_contents($tmpFile, $data);

$this->expectException(ConfigurationException::class);
$this->expectExceptionMessageMatches('/' . basename($tmpFile) . '/');
$this->expectExceptionMessageMatches('/The property unknownProperty is not defined and the definition does not allow additional properties/');

Importer::import($tmpFile);
}
}