File tree Expand file tree Collapse file tree 6 files changed +26
-19
lines changed Expand file tree Collapse file tree 6 files changed +26
-19
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace BeyondCode \QueryDetector \Outputs ;
4
4
5
- use Illuminate \Http \Response ;
6
5
use Illuminate \Support \Collection ;
6
+ use Symfony \Component \HttpFoundation \Response ;
7
7
8
8
class Alert implements Output
9
9
{
10
10
public function output (Collection $ detectedQueries , Response $ response )
11
11
{
12
+ if ($ response ->isRedirection ()) {
13
+ return ;
14
+ }
15
+
12
16
$ content = $ response ->getContent ();
13
17
14
18
$ outputContent = $ this ->getOutputContent ($ detectedQueries );
Original file line number Diff line number Diff line change 3
3
namespace BeyondCode \QueryDetector \Outputs ;
4
4
5
5
use Log as LaravelLog ;
6
- use Illuminate \Http \Response ;
7
6
use Illuminate \Support \Collection ;
7
+ use Symfony \Component \HttpFoundation \Response ;
8
8
9
9
class Log implements Output
10
10
{
Original file line number Diff line number Diff line change 2
2
3
3
namespace BeyondCode \QueryDetector \Outputs ;
4
4
5
- use Illuminate \Http \Response ;
6
5
use Illuminate \Support \Collection ;
6
+ use Symfony \Component \HttpFoundation \Response ;
7
7
8
8
interface Output
9
9
{
Original file line number Diff line number Diff line change 3
3
namespace BeyondCode \QueryDetector ;
4
4
5
5
use DB ;
6
- use Illuminate \Http \Response ;
7
6
use Illuminate \Support \Collection ;
8
7
use Illuminate \Database \Eloquent \Builder ;
8
+ use Symfony \Component \HttpFoundation \Response ;
9
9
use Illuminate \Database \Eloquent \Relations \Relation ;
10
10
11
11
class QueryDetector
Original file line number Diff line number Diff line change 2
2
3
3
namespace BeyondCode \QueryDetector \Tests ;
4
4
5
- use BeyondCode \QueryDetector \Tests \Models \Comment ;
6
5
use Route ;
7
6
use BeyondCode \QueryDetector \QueryDetector ;
8
7
use BeyondCode \QueryDetector \Tests \Models \Post ;
9
8
use BeyondCode \QueryDetector \Tests \Models \Author ;
9
+ use BeyondCode \QueryDetector \Tests \Models \Comment ;
10
10
11
11
class QueryDetectorTest extends TestCase
12
12
{
@@ -207,4 +207,21 @@ public function it_ignores_whitelisted_relations_with_attributes()
207
207
208
208
$ this ->assertCount (0 , $ queries );
209
209
}
210
+
211
+ /** @test */
212
+ public function it_ignores_redirects ()
213
+ {
214
+ Route::get ('/ ' , function (){
215
+ foreach (Post::all () as $ post ) {
216
+ $ post ->comments ;
217
+ }
218
+ return redirect ()->to ('/random ' );
219
+ });
220
+
221
+ $ this ->get ('/ ' );
222
+
223
+ $ queries = app (QueryDetector::class)->getDetectedQueries ();
224
+
225
+ $ this ->assertCount (1 , $ queries );
226
+ }
210
227
}
Original file line number Diff line number Diff line change @@ -43,20 +43,6 @@ protected function getEnvironmentSetUp($app)
43
43
]);
44
44
45
45
$ app ['config ' ]->set ('app.key ' , 'base64:6Cu/ozj4gPtIjmXjr8EdVnGFNsdRqZfHfVjQkmTlg4Y= ' );
46
-
47
-
48
- $ app ['config ' ]->set ('logging.default ' , 'test ' );
49
-
50
- $ app ['config ' ]->set ('logging.channels ' , [
51
- 'test ' => [
52
- 'driver ' => 'custom ' ,
53
- 'via ' => function () {
54
- $ monolog = new Logger ('test ' );
55
- $ monolog ->pushHandler (new TestHandler ());
56
- return $ monolog ;
57
- },
58
- ],
59
- ]);
60
46
}
61
47
62
48
You can’t perform that action at this time.
0 commit comments