1818class ServerTest extends TestCase
1919{
2020 /** @dataProvider dsnProvider */
21- public function test_dsn_parsing (string $ dsn , string $ expectedHost , ?string $ expectedUser , ?int $ expectedPort )
21+ public function test_dsn_parsing (string $ dsn , string $ expectedHost , ?string $ expectedUser , ?int $ expectedPort ): void
2222 {
2323 $ server = new Server ($ dsn );
2424
@@ -27,70 +27,69 @@ public function test_dsn_parsing(string $dsn, string $expectedHost, ?string $exp
2727 $ this ->assertSame ($ expectedPort , $ server ->getPort ());
2828 }
2929
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- */
34- public function test_dsn_parsing_error ()
30+ public function test_dsn_parsing_error (): void
3531 {
32+ $ this ->expectException (\EasyCorp \Bundle \EasyDeployBundle \Exception \ServerConfigurationException::class);
33+ $ this ->expectExceptionMessage ('The host is missing (define it as an IP address or a host name) ' );
34+
3635 new Server ('deployer@ ' );
3736 }
3837
3938 /** @dataProvider localDsnProvider */
40- public function test_local_dsn_parsing (string $ dsn )
39+ public function test_local_dsn_parsing (string $ dsn ): void
4140 {
4241 $ server = new Server ($ dsn );
4342
4443 $ this ->assertTrue ($ server ->isLocalHost ());
4544 }
4645
4746 /** @dataProvider sshConnectionStringProvider */
48- public function test_ssh_connection_string ($ dsn , $ expectedSshConnectionString )
47+ public function test_ssh_connection_string ($ dsn , $ expectedSshConnectionString ): void
4948 {
5049 $ server = new Server ($ dsn );
5150
5251 $ this ->assertSame ($ expectedSshConnectionString , $ server ->getSshConnectionString ());
5352 }
5453
55- public function test_ssh_agent_forwarding ()
54+ public function test_ssh_agent_forwarding (): void
5655 {
5756 $ server = new Server ('host ' );
5857 $ server ->set (Property::use_ssh_agent_forwarding, true );
5958
6059 $ this ->assertSame ('ssh -A host ' , $ server ->getSshConnectionString ());
6160 }
6261
63- public function test_default_server_roles ()
62+ public function test_default_server_roles (): void
6463 {
6564 $ server = new Server ('host ' );
6665
6766 $ this ->assertSame ([Server::ROLE_APP ], $ server ->getRoles ());
6867 }
6968
7069 /** @dataProvider serverRolesProvider */
71- public function test_server_roles (array $ definedRoles , array $ expectedRoles )
70+ public function test_server_roles (array $ definedRoles , array $ expectedRoles ): void
7271 {
7372 $ server = new Server ('host ' , $ definedRoles );
7473
7574 $ this ->assertSame ($ expectedRoles , $ server ->getRoles ());
7675 }
7776
78- public function test_default_server_properties ()
77+ public function test_default_server_properties (): void
7978 {
8079 $ server = new Server ('host ' );
8180
8281 $ this ->assertSame ([], $ server ->getProperties ());
8382 }
8483
85- public function test_server_properties ()
84+ public function test_server_properties (): void
8685 {
8786 $ properties = ['prop1 ' => -3.14 , 'prop2 ' => false , 'prop3 ' => 'Lorem Ipsum ' , 'prop4 ' => ['foo ' => 'bar ' ]];
8887 $ server = new Server ('host ' , [], $ properties );
8988
9089 $ this ->assertSame ($ properties , $ server ->getProperties ());
9190 }
9291
93- public function test_get_set_has_server_properties ()
92+ public function test_get_set_has_server_properties (): void
9493 {
9594 $ properties = ['prop1 ' => -3.14 , 'prop2 ' => false , 'prop3 ' => 'Lorem Ipsum ' , 'prop4 ' => ['foo ' => 'bar ' ]];
9695 $ server = new Server ('host ' );
@@ -106,7 +105,7 @@ public function test_get_set_has_server_properties()
106105 }
107106
108107 /** @dataProvider expressionProvider */
109- public function test_resolve_properties (array $ properties , string $ expression , string $ expectedExpression )
108+ public function test_resolve_properties (array $ properties , string $ expression , string $ expectedExpression ): void
110109 {
111110 $ server = new Server ('host ' , [], $ properties );
112111
@@ -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 */
121- public function test_resolve_unknown_properties (array $ properties , string $ expression )
118+ public function test_resolve_unknown_properties (array $ properties , string $ expression ): void
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 ' ];
173172174173 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