diff --git a/tests/Configuration/ConfigurationAdapterTest.php b/tests/Configuration/ConfigurationAdapterTest.php index e6bedbf..30b8021 100644 --- a/tests/Configuration/ConfigurationAdapterTest.php +++ b/tests/Configuration/ConfigurationAdapterTest.php @@ -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([]) diff --git a/tests/Configuration/DefaultConfigurationTest.php b/tests/Configuration/DefaultConfigurationTest.php index 7d3f1a1..47a18d6 100644 --- a/tests/Configuration/DefaultConfigurationTest.php +++ b/tests/Configuration/DefaultConfigurationTest.php @@ -18,22 +18,22 @@ 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(\EasyCorp\Bundle\EasyDeployBundle\Exception\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(\EasyCorp\Bundle\EasyDeployBundle\Exception\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') ; diff --git a/tests/Server/ServerRepositoryTest.php b/tests/Server/ServerRepositoryTest.php index a32d1ed..90e683d 100644 --- a/tests/Server/ServerRepositoryTest.php +++ b/tests/Server/ServerRepositoryTest.php @@ -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')); diff --git a/tests/Server/ServerTest.php b/tests/Server/ServerTest.php index c3960f9..2033f5f 100644 --- a/tests/Server/ServerTest.php +++ b/tests/Server/ServerTest.php @@ -27,12 +27,11 @@ 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(\EasyCorp\Bundle\EasyDeployBundle\Exception\ServerConfigurationException::class); + $this->expectExceptionMessage('The host is missing (define it as an IP address or a host name)'); + new Server('deployer@'); } @@ -115,11 +114,12 @@ 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); }