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 22
33namespace BeyondCode \QueryDetector \Outputs ;
44
5- use Illuminate \Http \Response ;
65use Illuminate \Support \Collection ;
6+ use Symfony \Component \HttpFoundation \Response ;
77
88class Alert implements Output
99{
1010 public function output (Collection $ detectedQueries , Response $ response )
1111 {
12+ if ($ response ->isRedirection ()) {
13+ return ;
14+ }
15+
1216 $ content = $ response ->getContent ();
1317
1418 $ outputContent = $ this ->getOutputContent ($ detectedQueries );
Original file line number Diff line number Diff line change 33namespace BeyondCode \QueryDetector \Outputs ;
44
55use Log as LaravelLog ;
6- use Illuminate \Http \Response ;
76use Illuminate \Support \Collection ;
7+ use Symfony \Component \HttpFoundation \Response ;
88
99class Log implements Output
1010{
Original file line number Diff line number Diff line change 22
33namespace BeyondCode \QueryDetector \Outputs ;
44
5- use Illuminate \Http \Response ;
65use Illuminate \Support \Collection ;
6+ use Symfony \Component \HttpFoundation \Response ;
77
88interface Output
99{
Original file line number Diff line number Diff line change 33namespace BeyondCode \QueryDetector ;
44
55use DB ;
6- use Illuminate \Http \Response ;
76use Illuminate \Support \Collection ;
87use Illuminate \Database \Eloquent \Builder ;
8+ use Symfony \Component \HttpFoundation \Response ;
99use Illuminate \Database \Eloquent \Relations \Relation ;
1010
1111class QueryDetector
Original file line number Diff line number Diff line change 22
33namespace BeyondCode \QueryDetector \Tests ;
44
5- use BeyondCode \QueryDetector \Tests \Models \Comment ;
65use Route ;
76use BeyondCode \QueryDetector \QueryDetector ;
87use BeyondCode \QueryDetector \Tests \Models \Post ;
98use BeyondCode \QueryDetector \Tests \Models \Author ;
9+ use BeyondCode \QueryDetector \Tests \Models \Comment ;
1010
1111class QueryDetectorTest extends TestCase
1212{
@@ -207,4 +207,21 @@ public function it_ignores_whitelisted_relations_with_attributes()
207207
208208 $ this ->assertCount (0 , $ queries );
209209 }
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+ }
210227}
Original file line number Diff line number Diff line change @@ -43,20 +43,6 @@ protected function getEnvironmentSetUp($app)
4343 ]);
4444
4545 $ 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- ]);
6046 }
6147
6248
You can’t perform that action at this time.
0 commit comments