@@ -19,20 +19,20 @@ public function test_no_rotate_if_file_logs_not_exits()
19
19
Event::assertDispatched (RotateHasFailed::class, 0 );
20
20
21
21
$ this ->assertEquals ($ resultCode , 0 );
22
- $ this ->assertFileDoesNotExist (app ()->storagePath (). '/logs/laravel.log.1.gz ' );
22
+ $ this ->assertFileDoesNotExist (app ()->storagePath () . '/logs/laravel.log.1.gz ' );
23
23
}
24
24
25
25
public function test_no_rotate_if_file_logs_is_empty ()
26
26
{
27
- touch (app ()->storagePath (). '/logs/laravel.log ' );
27
+ touch (app ()->storagePath () . '/logs/laravel.log ' );
28
28
29
29
$ resultCode = Artisan::call ('rotate:logs ' );
30
30
31
31
Event::assertDispatched (RotateWasSuccessful::class, 0 );
32
32
Event::assertDispatched (RotateHasFailed::class, 0 );
33
33
34
34
$ this ->assertEquals ($ resultCode , 0 );
35
- $ this ->assertFileDoesNotExist (app ()->storagePath (). '/logs/laravel.log.1.gz ' );
35
+ $ this ->assertFileDoesNotExist (app ()->storagePath () . '/logs/laravel.log.1.gz ' );
36
36
}
37
37
38
38
public function test_it_not_rotate_logs_daily ()
@@ -54,7 +54,7 @@ public function test_it_not_rotate_logs_daily()
54
54
$ this ->assertEquals ($ resultCode , 0 );
55
55
56
56
foreach ($ files as $ file ) {
57
- $ this ->assertFileDoesNotExist ($ file. '.1.gz ' );
57
+ $ this ->assertFileDoesNotExist ($ file . '.1.gz ' );
58
58
}
59
59
}
60
60
@@ -64,24 +64,24 @@ public function test_it_can_rotate_logs_custom_stream_file()
64
64
'driver ' => 'monolog ' ,
65
65
'handler ' => StreamHandler::class,
66
66
'with ' => [
67
- 'stream ' => app ()->storagePath (). '/logs/custom.log ' ,
67
+ 'stream ' => app ()->storagePath () . '/logs/custom.log ' ,
68
68
],
69
69
]);
70
70
71
71
$ this ->app ['config ' ]->set ('logging.default ' , 'custom ' );
72
72
73
73
$ this ->writeLog ();
74
74
75
- $ this ->assertFileExists (app ()->storagePath (). '/logs/custom.log ' );
75
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/custom.log ' );
76
76
77
77
$ resultCode = Artisan::call ('rotate:logs ' );
78
78
79
79
Event::assertDispatched (RotateWasSuccessful::class, 1 );
80
80
81
81
$ this ->assertEquals ($ resultCode , 0 );
82
- $ this ->assertFileExists (app ()->storagePath (). '/logs/custom.log.1.gz ' );
82
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/custom.log.1.gz ' );
83
83
84
- unlink (app ()->storagePath (). '/logs/custom.log.1.gz ' );
84
+ unlink (app ()->storagePath () . '/logs/custom.log.1.gz ' );
85
85
}
86
86
87
87
public function test_it_not_rotate_logs_custom_stream_std ()
@@ -108,18 +108,50 @@ public function test_it_can_write_log_after_rotate()
108
108
{
109
109
$ this ->writeLog ();
110
110
111
- $ this ->assertFileExists (app ()->storagePath (). '/logs/laravel.log ' );
111
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log ' );
112
112
113
113
$ resultCode = Artisan::call ('rotate:logs ' );
114
114
115
115
Event::assertDispatched (RotateWasSuccessful::class, 1 );
116
116
117
117
$ this ->assertEquals ($ resultCode , 0 );
118
- $ this ->assertFileExists (app ()->storagePath (). '/logs/laravel.log.1.gz ' );
118
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log.1.gz ' );
119
119
120
120
$ this ->writeLog ();
121
121
122
- //$this->assertGreaterThan(0, filesize(app()->storagePath().'/logs/laravel.log'));
122
+ $ this ->assertGreaterThan (0 , filesize (app ()->storagePath () . '/logs/laravel.log ' ));
123
+ }
124
+
125
+ public function test_log_file_exits_if_truncate_enable ()
126
+ {
127
+ $ this ->app ['config ' ]->set ('rotate.truncate ' , true );
128
+ $ this ->writeLog ();
129
+
130
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log ' );
131
+
132
+ $ resultCode = Artisan::call ('rotate:logs ' );
133
+
134
+ Event::assertDispatched (RotateWasSuccessful::class, 1 );
135
+
136
+ $ this ->assertEquals ($ resultCode , 0 );
137
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log.1.gz ' );
138
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log ' );
139
+ }
140
+
141
+ public function test_log_file_does_not_exits_if_truncate_disable ()
142
+ {
143
+ $ this ->app ['config ' ]->set ('rotate.truncate ' , false );
144
+ $ this ->writeLog ();
145
+
146
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log ' );
147
+
148
+ $ resultCode = Artisan::call ('rotate:logs ' );
149
+
150
+ Event::assertDispatched (RotateWasSuccessful::class, 1 );
151
+
152
+ $ this ->assertEquals ($ resultCode , 0 );
153
+ $ this ->assertFileExists (app ()->storagePath () . '/logs/laravel.log.1.gz ' );
154
+ $ this ->assertFileDoesNotExist (app ()->storagePath () . '/logs/laravel.log ' );
123
155
}
124
156
125
157
public function test_rotate_foreing_files ()
0 commit comments