44
55namespace VasekPurchart \Phing \SymfonyCommand ;
66
7+ use Generator ;
78use PHPUnit \Framework \Assert ;
89use Project ;
910use VasekPurchart \Phing \PhingTester \PhingTester ;
1011
1112class SymfonyCommandTaskIntegrationTest extends \PHPUnit \Framework \TestCase
1213{
1314
14- public function testCallCommand (): void
15+ /**
16+ * @return mixed[][]|\Generator
17+ */
18+ public function callCommandDataProvider (): Generator
1519 {
16- $ tester = new PhingTester (__DIR__ . '/symfony-command-task-integration-test.xml ' );
17- $ target = __FUNCTION__ ;
18- $ tester ->executeTarget ($ target );
19-
20- $ tester ->assertLogMessageRegExp (sprintf (
21- '~executing.+%s.+%s.+hello:world~i ' ,
22- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.default.executable ' ),
23- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.default.app ' )
24- ), $ target , Project::MSG_VERBOSE );
20+ yield 'call command ' => (static function (): array {
21+ $ target = 'testCallCommand ' ;
22+
23+ return [
24+ 'target ' => $ target ,
25+ 'propertyNameWithExpectedExecutable ' => $ target . '.default.executable ' ,
26+ 'propertyNameWithExpectedApp ' => $ target . '.default.app ' ,
27+ ];
28+ })();
29+
30+ yield 'call command with custom executable ' => (static function (): array {
31+ $ target = 'testCallCommandWithCustomExecutable ' ;
32+
33+ return [
34+ 'target ' => $ target ,
35+ 'propertyNameWithExpectedExecutable ' => $ target . '.test.executable ' ,
36+ 'propertyNameWithExpectedApp ' => $ target . '.default.app ' ,
37+ ];
38+ })();
39+
40+ yield 'call command with custom app ' => (static function (): array {
41+ $ target = 'testCallCommandWithCustomApp ' ;
42+
43+ return [
44+ 'target ' => $ target ,
45+ 'propertyNameWithExpectedExecutable ' => $ target . '.default.executable ' ,
46+ 'propertyNameWithExpectedApp ' => $ target . '.test.app ' ,
47+ ];
48+ })();
49+
50+ yield 'call command with custom executable and app ' => (static function (): array {
51+ $ target = 'testCallCommandWithCustomExecutableAndApp ' ;
52+
53+ return [
54+ 'target ' => $ target ,
55+ 'propertyNameWithExpectedExecutable ' => $ target . '.test.executable ' ,
56+ 'propertyNameWithExpectedApp ' => $ target . '.test.app ' ,
57+ ];
58+ })();
59+
60+ yield 'call command and override defaults ' => (static function (): array {
61+ $ target = 'testCallCommandAndOverrideDefaults ' ;
62+
63+ return [
64+ 'target ' => $ target ,
65+ 'propertyNameWithExpectedExecutable ' => $ target . '.test.executable ' ,
66+ 'propertyNameWithExpectedApp ' => $ target . '.test.app ' ,
67+ ];
68+ })();
2569 }
2670
27- public function testCallCommandWithCustomExecutable (): void
71+ /**
72+ * @dataProvider callCommandDataProvider
73+ *
74+ * @param string $target
75+ * @param string $propertyNameWithExpectedExecutable
76+ * @param string $propertyNameWithExpectedApp
77+ */
78+ public function testCallCommand (
79+ string $ target ,
80+ string $ propertyNameWithExpectedExecutable ,
81+ string $ propertyNameWithExpectedApp
82+ ): void
2883 {
2984 $ tester = new PhingTester (__DIR__ . '/symfony-command-task-integration-test.xml ' );
30- $ target = __FUNCTION__ ;
3185 $ tester ->executeTarget ($ target );
3286
3387 $ tester ->assertLogMessageRegExp (sprintf (
3488 '~executing.+%s.+%s.+hello:world~i ' ,
35- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.executable ' ),
36- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.default.app ' )
37- ), $ target , Project::MSG_VERBOSE );
38- }
39-
40- public function testCallCommandWithCustomApp (): void
41- {
42- $ tester = new PhingTester (__DIR__ . '/symfony-command-task-integration-test.xml ' );
43- $ target = __FUNCTION__ ;
44- $ tester ->executeTarget ($ target );
45-
46- $ tester ->assertLogMessageRegExp (sprintf (
47- '~executing.+%s.+%s.+hello:world~i ' ,
48- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.default.executable ' ),
49- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.app ' )
50- ), $ target , Project::MSG_VERBOSE );
51- }
52-
53- public function testCallCommandWithCustomExecutableAndApp (): void
54- {
55- $ tester = new PhingTester (__DIR__ . '/symfony-command-task-integration-test.xml ' );
56- $ target = __FUNCTION__ ;
57- $ tester ->executeTarget ($ target );
58-
59- $ tester ->assertLogMessageRegExp (sprintf (
60- '~executing.+%s.+%s.+hello:world~i ' ,
61- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.executable ' ),
62- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.app ' )
89+ $ tester ->getProject ()->getProperty ($ propertyNameWithExpectedExecutable ),
90+ $ tester ->getProject ()->getProperty ($ propertyNameWithExpectedApp )
6391 ), $ target , Project::MSG_VERBOSE );
6492 }
6593
@@ -75,19 +103,6 @@ public function testCallCommandWithAppAsExecutable(): void
75103 ), $ target , Project::MSG_VERBOSE );
76104 }
77105
78- public function testCallCommandAndOverrideDefaults (): void
79- {
80- $ tester = new PhingTester (__DIR__ . '/symfony-command-task-integration-test.xml ' );
81- $ target = __FUNCTION__ ;
82- $ tester ->executeTarget ($ target );
83-
84- $ tester ->assertLogMessageRegExp (sprintf (
85- '~executing.+%s.+%s.+hello:world~i ' ,
86- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.executable ' ),
87- $ tester ->getProject ()->getProperty (__FUNCTION__ . '.test.app ' )
88- ), $ target , Project::MSG_VERBOSE );
89- }
90-
91106 public function testMissingApp (): void
92107 {
93108 $ buildFilePath = __DIR__ . '/symfony-command-task-integration-test.xml ' ;
0 commit comments