2
2
3
3
use Potsky \LaravelLocalizationHelpers \Factory \Localization ;
4
4
use Potsky \LaravelLocalizationHelpers \Factory \MessageBag ;
5
- use Symfony \Component \Console \Output \BufferedOutput ;
6
5
7
6
class CommandClearTests extends TestCase
8
7
{
@@ -37,10 +36,8 @@ public function setUp()
37
36
*/
38
37
public function testCleanAll ()
39
38
{
40
- $ output = new BufferedOutput ;
41
-
42
39
/** @noinspection PhpVoidFunctionResultUsedInspection */
43
- $ return = Artisan::call ( 'localization:clear ' , array () , $ output );
40
+ $ return = Artisan::call ( 'localization:clear ' , array () );
44
41
45
42
$ this ->assertEquals ( 0 , $ return );
46
43
$ this ->assertCount ( 0 , glob ( self ::LANG_DIR_PATH . '/*/message*.php ' ) );
@@ -51,10 +48,8 @@ public function testCleanAll()
51
48
*/
52
49
public function testClean30Days ()
53
50
{
54
- $ output = new BufferedOutput ;
55
-
56
51
/** @noinspection PhpVoidFunctionResultUsedInspection */
57
- $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => 30 ) , $ output );
52
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => 30 ) );
58
53
59
54
$ this ->assertEquals ( 0 , $ return );
60
55
$ this ->assertCount ( 20 , glob ( self ::LANG_DIR_PATH . '/*/message*.php ' ) );
@@ -65,10 +60,8 @@ public function testClean30Days()
65
60
*/
66
61
public function testClean3Days ()
67
62
{
68
- $ output = new BufferedOutput ;
69
-
70
63
/** @noinspection PhpVoidFunctionResultUsedInspection */
71
- $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => 3 ) , $ output );
64
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => 3 ) );
72
65
73
66
$ this ->assertEquals ( 0 , $ return );
74
67
$ this ->assertCount ( 6 , glob ( self ::LANG_DIR_PATH . '/*/message*.php ' ) );
@@ -79,10 +72,8 @@ public function testClean3Days()
79
72
*/
80
73
public function testErrorDaysNegative ()
81
74
{
82
- $ output = new BufferedOutput ;
83
-
84
75
/** @noinspection PhpVoidFunctionResultUsedInspection */
85
- $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => -3 ) , $ output );
76
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--days ' => -3 ) );
86
77
$ this ->assertEquals ( 1 , $ return );
87
78
88
79
$ manager = new Localization ( new MessageBag () );
@@ -94,10 +85,8 @@ public function testErrorDaysNegative()
94
85
*/
95
86
public function testDryRun ()
96
87
{
97
- $ output = new BufferedOutput ;
98
-
99
88
/** @noinspection PhpVoidFunctionResultUsedInspection */
100
- $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) , $ output );
89
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) );
101
90
102
91
$ this ->assertEquals ( 0 , $ return );
103
92
$ this ->assertCount ( 20 , glob ( self ::LANG_DIR_PATH . '/*/message*.php ' ) );
@@ -111,29 +100,26 @@ public function testLangFolderDoesNotExist()
111
100
{
112
101
Config::set ( Localization::PREFIX_LARAVEL_CONFIG . 'lang_folder_path ' , self ::LANG_DIR_PATH . 'doesnotexist ' );
113
102
114
- $ output = new BufferedOutput ;
115
-
116
103
/** @noinspection PhpVoidFunctionResultUsedInspection */
117
- $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) , $ output );
104
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) );
118
105
119
106
$ this ->assertEquals ( 1 , $ return );
120
- $ this ->assertContains ( 'No lang folder found in your custom path: ' , $ output-> fetch () );
107
+ $ this ->assertContains ( 'No lang folder found in your custom path: ' , Artisan:: output () );
121
108
}
122
109
123
110
/**
124
111
* - Default lang folders are used when custom land folder path as not been set by user
112
+ *
113
+ * In Laravel 5.x, orchestra/testbench has not empty lang en directory, so return code is 0 and not 1
125
114
*/
126
115
public function testDefaultLangFolderDoesNotExist ()
127
116
{
128
117
Config::set ( Localization::PREFIX_LARAVEL_CONFIG . 'lang_folder_path ' , null );
129
118
130
- $ output = new BufferedOutput ;
131
-
132
119
/** @noinspection PhpVoidFunctionResultUsedInspection */
133
- $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) , $ output );
120
+ $ return = Artisan::call ( 'localization:clear ' , array ( '--dry-run ' => true ) );
134
121
135
- $ this ->assertEquals ( 1 , $ return );
136
- $ this ->assertContains ( 'No lang folder found in these paths: ' , $ output ->fetch () );
122
+ $ this ->assertEquals ( 0 , $ return );
137
123
}
138
124
139
125
}
0 commit comments