@@ -26,42 +26,48 @@ class TranslationDebugCommandTest extends TestCase
26
26
public function testDebugMissingMessages ()
27
27
{
28
28
$ tester = $ this ->createCommandTester (['foo ' => 'foo ' ]);
29
- $ tester ->execute (['locale ' => 'en ' , 'bundle ' => 'foo ' ]);
29
+ $ res = $ tester ->execute (['locale ' => 'en ' , 'bundle ' => 'foo ' ]);
30
30
31
31
$ this ->assertRegExp ('/missing/ ' , $ tester ->getDisplay ());
32
+ $ this ->assertEquals (TranslationDebugCommand::EXIT_CODE_MISSING , $ res );
32
33
}
33
34
34
35
public function testDebugUnusedMessages ()
35
36
{
36
37
$ tester = $ this ->createCommandTester ([], ['foo ' => 'foo ' ]);
37
- $ tester ->execute (['locale ' => 'en ' , 'bundle ' => 'foo ' ]);
38
+ $ res = $ tester ->execute (['locale ' => 'en ' , 'bundle ' => 'foo ' ]);
38
39
39
40
$ this ->assertRegExp ('/unused/ ' , $ tester ->getDisplay ());
41
+ $ this ->assertEquals (TranslationDebugCommand::EXIT_CODE_UNUSED , $ res );
40
42
}
41
43
42
44
public function testDebugFallbackMessages ()
43
45
{
44
- $ tester = $ this ->createCommandTester ([], ['foo ' => 'foo ' ]);
45
- $ tester ->execute (['locale ' => 'fr ' , 'bundle ' => 'foo ' ]);
46
+ $ tester = $ this ->createCommandTester ([' foo ' => ' foo ' ], ['foo ' => 'foo ' ]);
47
+ $ res = $ tester ->execute (['locale ' => 'fr ' , 'bundle ' => 'foo ' ]);
46
48
47
49
$ this ->assertRegExp ('/fallback/ ' , $ tester ->getDisplay ());
50
+ $ this ->assertEquals (TranslationDebugCommand::EXIT_CODE_FALLBACK , $ res );
48
51
}
49
52
50
53
public function testNoDefinedMessages ()
51
54
{
52
55
$ tester = $ this ->createCommandTester ();
53
- $ tester ->execute (['locale ' => 'fr ' , 'bundle ' => 'test ' ]);
56
+ $ res = $ tester ->execute (['locale ' => 'fr ' , 'bundle ' => 'test ' ]);
54
57
55
58
$ this ->assertRegExp ('/No defined or extracted messages for locale "fr"/ ' , $ tester ->getDisplay ());
59
+ $ this ->assertEquals (TranslationDebugCommand::EXIT_CODE_GENERAL_ERROR , $ res );
56
60
}
57
61
58
62
public function testDebugDefaultDirectory ()
59
63
{
60
64
$ tester = $ this ->createCommandTester (['foo ' => 'foo ' ], ['bar ' => 'bar ' ]);
61
- $ tester ->execute (['locale ' => 'en ' ]);
65
+ $ res = $ tester ->execute (['locale ' => 'en ' ]);
66
+ $ expectedExitStatus = TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED ;
62
67
63
68
$ this ->assertRegExp ('/missing/ ' , $ tester ->getDisplay ());
64
69
$ this ->assertRegExp ('/unused/ ' , $ tester ->getDisplay ());
70
+ $ this ->assertEquals ($ expectedExitStatus , $ res );
65
71
}
66
72
67
73
public function testDebugDefaultRootDirectory ()
@@ -72,11 +78,14 @@ public function testDebugDefaultRootDirectory()
72
78
$ this ->fs ->mkdir ($ this ->translationDir .'/translations ' );
73
79
$ this ->fs ->mkdir ($ this ->translationDir .'/templates ' );
74
80
81
+ $ expectedExitStatus = TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED ;
82
+
75
83
$ tester = $ this ->createCommandTester (['foo ' => 'foo ' ], ['bar ' => 'bar ' ], null , [$ this ->translationDir .'/trans ' ], [$ this ->translationDir .'/views ' ]);
76
- $ tester ->execute (['locale ' => 'en ' ]);
84
+ $ res = $ tester ->execute (['locale ' => 'en ' ]);
77
85
78
86
$ this ->assertRegExp ('/missing/ ' , $ tester ->getDisplay ());
79
87
$ this ->assertRegExp ('/unused/ ' , $ tester ->getDisplay ());
88
+ $ this ->assertEquals ($ expectedExitStatus , $ res );
80
89
}
81
90
82
91
public function testDebugCustomDirectory ()
@@ -89,11 +98,14 @@ public function testDebugCustomDirectory()
89
98
->with ($ this ->equalTo ($ this ->translationDir .'/customDir ' ))
90
99
->willThrowException (new \InvalidArgumentException ());
91
100
101
+ $ expectedExitStatus = TranslationDebugCommand::EXIT_CODE_MISSING | TranslationDebugCommand::EXIT_CODE_UNUSED ;
102
+
92
103
$ tester = $ this ->createCommandTester (['foo ' => 'foo ' ], ['bar ' => 'bar ' ], $ kernel );
93
- $ tester ->execute (['locale ' => 'en ' , 'bundle ' => $ this ->translationDir .'/customDir ' ]);
104
+ $ res = $ tester ->execute (['locale ' => 'en ' , 'bundle ' => $ this ->translationDir .'/customDir ' ]);
94
105
95
106
$ this ->assertRegExp ('/missing/ ' , $ tester ->getDisplay ());
96
107
$ this ->assertRegExp ('/unused/ ' , $ tester ->getDisplay ());
108
+ $ this ->assertEquals ($ expectedExitStatus , $ res );
97
109
}
98
110
99
111
/**
0 commit comments