Skip to content

Commit b698a48

Browse files
committed
Add Symfony 6 compatibility remove Symfony 2-3-4
1 parent 8357c08 commit b698a48

8 files changed

+34
-31
lines changed

composer.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
],
1414
"require": {
1515
"php": ">=7.2.0",
16-
"symfony/console": "~2.3|~3.0|~4.0|~5.0",
17-
"symfony/dependency-injection": "~2.3|~3.0|~4.0|~5.0",
18-
"symfony/expression-language": "~2.4|~3.0|~4.0|~5.0",
19-
"symfony/filesystem": "~2.3|~3.0|~4.0|~5.0",
20-
"symfony/http-foundation": "~2.3|~3.0|~4.0|~5.0",
21-
"symfony/http-kernel": "~2.3|~3.0|~4.0|~5.0",
16+
"symfony/config": "~5.0|~6.0",
17+
"symfony/console": "~5.0|~6.0",
18+
"symfony/dependency-injection": "~5.0|~6.0",
19+
"symfony/expression-language": "~5.0|~6.0",
20+
"symfony/filesystem": "~5.0|~6.0",
21+
"symfony/http-foundation": "~5.0|~6.0",
22+
"symfony/http-kernel": "~5.0|~6.0",
2223
"symfony/polyfill-mbstring": "^1.3",
23-
"symfony/process": "~2.3|~3.0|~4.0|~5.0"
24+
"symfony/process": "~5.0|~6.0"
2425
},
2526
"require-dev": {
26-
"phpunit/phpunit": "^6.1"
27+
"phpunit/phpunit": "9.5.*"
2728
},
2829
"config": {
2930
"sort-packages": true

src/Command/DeployCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
6969
$this->createDefaultConfigFile($input, $output, $defaultConfigPath, $input->getArgument('stage'));
7070
}
7171

72-
protected function execute(InputInterface $input, OutputInterface $output)
72+
protected function execute(InputInterface $input, OutputInterface $output): int
7373
{
7474
$logFilePath = sprintf('%s/deploy_%s.log', $this->logDir, $input->getArgument('stage'));
7575
$context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose());

src/Command/RollbackCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
6464
throw new \RuntimeException(sprintf("The default configuration file does not exist or it's not readable, and no custom configuration file was given either. Create the '%s' configuration file and run this command again.", $defaultConfigPath));
6565
}
6666

67-
protected function execute(InputInterface $input, OutputInterface $output)
67+
protected function execute(InputInterface $input, OutputInterface $output): int
6868
{
6969
$logFilePath = sprintf('%s/deploy_%s.log', $this->logDir, $input->getArgument('stage'));
7070
$context = new Context($input, $output, $this->projectDir, $logFilePath, true === $input->getOption('dry-run'), $output->isVerbose());

src/Deployer/DefaultDeployer.php

+2
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ private function findConsoleBinaryPath(Server $server): string
224224
if (null === $server->get(Property::console_bin)) {
225225
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)));
226226
}
227+
228+
return $server->resolveProperties('{{ project_dir }}/bin/console');
227229
}
228230

229231
private function createRemoteDirectoryLayout(): void

tests/Configuration/ConfigurationAdapterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ConfigurationAdapterTest extends TestCase
2121
/** @var DefaultConfiguration */
2222
private $config;
2323

24-
protected function setUp()
24+
protected function setUp(): void
2525
{
2626
$this->config = (new DefaultConfiguration(__DIR__))
2727
->sharedFilesAndDirs([])

tests/Configuration/DefaultConfigurationTest.php

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,35 @@
1212
namespace EasyCorp\Bundle\EasyDeployBundle\Tests;
1313

1414
use EasyCorp\Bundle\EasyDeployBundle\Configuration\DefaultConfiguration;
15+
use EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class DefaultConfigurationTest extends TestCase
1819
{
1920
/**
2021
* @dataProvider provideHttpRepositoryUrls
21-
* @expectedException \EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException
22-
* @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"/
2322
*/
2423
public function test_repository_url_protocol(string $url)
2524
{
25+
$this->expectException(InvalidConfigurationException::class);
26+
$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"/');
27+
2628
(new DefaultConfiguration(__DIR__))
2729
->repositoryUrl($url)
2830
;
2931
}
3032

31-
/**
32-
* @expectedException \EasyCorp\Bundle\EasyDeployBundle\Exception\InvalidConfigurationException
33-
* @expectedExceptionMessage The value of resetOpCacheFor option must be the valid URL of your homepage (it must start with http:// or https://).
34-
*/
3533
public function test_reset_opcache_for()
3634
{
35+
$this->expectException(InvalidConfigurationException::class);
36+
$this->expectExceptionMessage('The value of resetOpCacheFor option must be the valid URL of your homepage (it must start with http:// or https://).');
37+
3738
(new DefaultConfiguration(__DIR__))
3839
->resetOpCacheFor('symfony.com')
3940
;
4041
}
4142

42-
public function provideHttpRepositoryUrls()
43+
public function provideHttpRepositoryUrls(): \Generator
4344
{
4445
yield ['http://github.com/symfony/symfony-demo.git'];
4546
yield ['https://github.com/symfony/symfony-demo.git'];

tests/Server/ServerRepositoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ServerRepositoryTest extends TestCase
2020
/** @var ServerRepository */
2121
private $servers;
2222

23-
protected function setUp()
23+
protected function setUp(): void
2424
{
2525
$repository = new ServerRepository();
2626
$repository->add(new Server('host0'));

tests/Server/ServerTest.php

+11-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace EasyCorp\Bundle\EasyDeployBundle\EasyDeployBundle\Tests;
1313

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

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

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

116115
/**
117116
* @dataProvider wrongExpressionProvider
118-
* @expectedException \InvalidArgumentException
119-
* @expectedExceptionMessageRegExp /The ".*" property in ".*" expression is not a valid server property./
120117
*/
121118
public function test_resolve_unknown_properties(array $properties, string $expression)
122119
{
120+
$this->expectException(\InvalidArgumentException::class);
121+
$this->expectExceptionMessageMatches('/The ".*" property in ".*" expression is not a valid server property./');
123122
$server = new Server('host', [], $properties);
124123
$server->resolveProperties($expression);
125124
}
126125

127-
public function dsnProvider()
126+
public function dsnProvider(): \Generator
128127
{
129128
yield ['123.123.123.123', '123.123.123.123', null, null];
130129
yield ['[email protected]', '123.123.123.123', 'deployer', null];
@@ -143,7 +142,7 @@ public function dsnProvider()
143142
yield ['ssh://deployer@host:22001', 'host', 'deployer', 22001];
144143
}
145144

146-
public function localDsnProvider()
145+
public function localDsnProvider(): \Generator
147146
{
148147
yield ['local'];
149148
yield ['deployer@local'];
@@ -158,23 +157,23 @@ public function localDsnProvider()
158157
yield ['[email protected]:22001'];
159158
}
160159

161-
public function serverRolesProvider()
160+
public function serverRolesProvider(): \Generator
162161
{
163162
yield [[], []];
164163
yield [[Server::ROLE_APP], [Server::ROLE_APP]];
165164
yield [['custom_role'], ['custom_role']];
166165
yield [['custom_role_1', 'custom_role_2'], ['custom_role_1', 'custom_role_2']];
167166
}
168167

169-
public function sshConnectionStringProvider()
168+
public function sshConnectionStringProvider(): \Generator
170169
{
171170
yield ['localhost', ''];
172171
yield ['123.123.123.123', 'ssh 123.123.123.123'];
173172
174173
yield ['[email protected]:22001', 'ssh [email protected] -p 22001'];
175174
}
176175

177-
public function expressionProvider()
176+
public function expressionProvider(): \Generator
178177
{
179178
yield [['prop1' => 'aaa'], '{{ prop1 }}', 'aaa'];
180179
yield [['prop.1' => 'aaa'], '{{ prop.1 }}', 'aaa'];
@@ -188,7 +187,7 @@ public function expressionProvider()
188187
yield [['prop1' => 'aaa', 'prop2' => 'bbb'], 'cd {{ prop1 }}{{ prop2 }}', 'cd aaabbb'];
189188
}
190189

191-
public function wrongExpressionProvider()
190+
public function wrongExpressionProvider(): \Generator
192191
{
193192
yield [[], '{{ prop1 }}'];
194193
yield [['prop1' => 'aaa'], '{{ prop 1 }}'];

0 commit comments

Comments
 (0)