Skip to content

Commit

Permalink
Add Symfony 6 compatibility remove Symfony 2-3-4
Browse files Browse the repository at this point in the history
  • Loading branch information
tcheymol committed Jan 7, 2022
1 parent 8357c08 commit bbca1d8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
17 changes: 9 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
],
"require": {
"php": ">=7.2.0",
"symfony/console": "~2.3|~3.0|~4.0|~5.0",
"symfony/dependency-injection": "~2.3|~3.0|~4.0|~5.0",
"symfony/expression-language": "~2.4|~3.0|~4.0|~5.0",
"symfony/filesystem": "~2.3|~3.0|~4.0|~5.0",
"symfony/http-foundation": "~2.3|~3.0|~4.0|~5.0",
"symfony/http-kernel": "~2.3|~3.0|~4.0|~5.0",
"symfony/config": "~5.0|~6.0",
"symfony/console": "~5.0|~6.0",
"symfony/dependency-injection": "~5.0|~6.0",
"symfony/expression-language": "~5.0|~6.0",
"symfony/filesystem": "~5.0|~6.0",
"symfony/http-foundation": "~5.0|~6.0",
"symfony/http-kernel": "~5.0|~6.0",
"symfony/polyfill-mbstring": "^1.3",
"symfony/process": "~2.3|~3.0|~4.0|~5.0"
"symfony/process": "~5.0|~6.0"
},
"require-dev": {
"phpunit/phpunit": "^6.1"
"phpunit/phpunit": "9.5.*"
},
"config": {
"sort-packages": true
Expand Down
2 changes: 2 additions & 0 deletions src/Deployer/DefaultDeployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ private function findConsoleBinaryPath(Server $server): string
if (null === $server->get(Property::console_bin)) {
throw new InvalidConfigurationException(sprintf('The "console" binary of your Symfony application is not available in any of the following directories: %s. Configure the "binDir" option and set it to the directory that contains the "console" binary.', implode(', ', $symfonyConsoleBinaries)));
}

return $server->resolveProperties('{{ project_dir }}/bin/console');
}

private function createRemoteDirectoryLayout(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Configuration/ConfigurationAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConfigurationAdapterTest extends TestCase
/** @var DefaultConfiguration */
private $config;

protected function setUp()
protected function setUp(): void
{
$this->config = (new DefaultConfiguration(__DIR__))
->sharedFilesAndDirs([])
Expand Down
15 changes: 8 additions & 7 deletions tests/Configuration/DefaultConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,35 @@
namespace EasyCorp\Bundle\EasyDeployBundle\Tests;

use EasyCorp\Bundle\EasyDeployBundle\Configuration\DefaultConfiguration;
use EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException;
use PHPUnit\Framework\TestCase;

class DefaultConfigurationTest extends TestCase
{
/**
* @dataProvider provideHttpRepositoryUrls
* @expectedException \EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException
* @expectedExceptionMessageRegExp /The repository URL must use the SSH syntax instead of the HTTPs syntax to make it work on any remote server. Replace "https?:\/\/.*\/symfony\/symfony-demo.git" by "git@.*:symfony\/symfony-demo.git"/
*/
public function test_repository_url_protocol(string $url)
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessageMatches('/The repository URL must use the SSH syntax instead of the HTTPs syntax to make it work on any remote server. Replace "https?:\/\/.*\/symfony\/symfony-demo.git" by "git@.*:symfony\/symfony-demo.git"/');

(new DefaultConfiguration(__DIR__))
->repositoryUrl($url)
;
}

/**
* @expectedException \EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException
* @expectedExceptionMessage The value of resetOpCacheFor option must be the valid URL of your homepage (it must start with http:// or https://).
*/
public function test_reset_opcache_for()
{
$this->expectException(InvalidConfigurationException::class);
$this->expectExceptionMessage('The value of resetOpCacheFor option must be the valid URL of your homepage (it must start with http:// or https://).');

(new DefaultConfiguration(__DIR__))
->resetOpCacheFor('symfony.com')
;
}

public function provideHttpRepositoryUrls()
public function provideHttpRepositoryUrls(): \Generator
{
yield ['http://github.com/symfony/symfony-demo.git'];
yield ['https://github.com/symfony/symfony-demo.git'];
Expand Down
2 changes: 1 addition & 1 deletion tests/Server/ServerRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ServerRepositoryTest extends TestCase
/** @var ServerRepository */
private $servers;

protected function setUp()
protected function setUp(): void
{
$repository = new ServerRepository();
$repository->add(new Server('host0'));
Expand Down
23 changes: 11 additions & 12 deletions tests/Server/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace EasyCorp\Bundle\EasyDeployBundle\EasyDeployBundle\Tests;

use EasyCorp\Bundle\EasyDeployBundle\Exception\ServerConfigurationException;
use EasyCorp\Bundle\EasyDeployBundle\Server\Property;
use EasyCorp\Bundle\EasyDeployBundle\Server\Server;
use PHPUnit\Framework\TestCase;
Expand All @@ -27,12 +28,10 @@ public function test_dsn_parsing(string $dsn, string $expectedHost, ?string $exp
$this->assertSame($expectedPort, $server->getPort());
}

/**
* @expectedException \EasyCorp\Bundle\EasyDeployBundle\Exception\ServerConfigurationException
* @expectedExceptionMessage The host is missing (define it as an IP address or a host name)
*/
public function test_dsn_parsing_error()
{
$this->expectException(ServerConfigurationException::class);
$this->expectExceptionMessage('The host is missing (define it as an IP address or a host name)');
new Server('deployer@');
}

Expand Down Expand Up @@ -115,16 +114,16 @@ public function test_resolve_properties(array $properties, string $expression, s

/**
* @dataProvider wrongExpressionProvider
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageRegExp /The ".*" property in ".*" expression is not a valid server property./
*/
public function test_resolve_unknown_properties(array $properties, string $expression)
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessageMatches('/The ".*" property in ".*" expression is not a valid server property./');
$server = new Server('host', [], $properties);
$server->resolveProperties($expression);
}

public function dsnProvider()
public function dsnProvider(): \Generator
{
yield ['123.123.123.123', '123.123.123.123', null, null];
yield ['[email protected]', '123.123.123.123', 'deployer', null];
Expand All @@ -143,7 +142,7 @@ public function dsnProvider()
yield ['ssh://deployer@host:22001', 'host', 'deployer', 22001];
}

public function localDsnProvider()
public function localDsnProvider(): \Generator
{
yield ['local'];
yield ['deployer@local'];
Expand All @@ -158,23 +157,23 @@ public function localDsnProvider()
yield ['[email protected]:22001'];
}

public function serverRolesProvider()
public function serverRolesProvider(): \Generator
{
yield [[], []];
yield [[Server::ROLE_APP], [Server::ROLE_APP]];
yield [['custom_role'], ['custom_role']];
yield [['custom_role_1', 'custom_role_2'], ['custom_role_1', 'custom_role_2']];
}

public function sshConnectionStringProvider()
public function sshConnectionStringProvider(): \Generator
{
yield ['localhost', ''];
yield ['123.123.123.123', 'ssh 123.123.123.123'];
yield ['[email protected]', 'ssh [email protected]'];
yield ['[email protected]:22001', 'ssh [email protected] -p 22001'];
}

public function expressionProvider()
public function expressionProvider(): \Generator
{
yield [['prop1' => 'aaa'], '{{ prop1 }}', 'aaa'];
yield [['prop.1' => 'aaa'], '{{ prop.1 }}', 'aaa'];
Expand All @@ -188,7 +187,7 @@ public function expressionProvider()
yield [['prop1' => 'aaa', 'prop2' => 'bbb'], 'cd {{ prop1 }}{{ prop2 }}', 'cd aaabbb'];
}

public function wrongExpressionProvider()
public function wrongExpressionProvider(): \Generator
{
yield [[], '{{ prop1 }}'];
yield [['prop1' => 'aaa'], '{{ prop 1 }}'];
Expand Down

0 comments on commit bbca1d8

Please sign in to comment.