@@ -56,11 +56,7 @@ public function test_scopes_are_applied_to_query()
5656 {
5757 $ query = ModelWithGlobalScopeTestStub::query ();
5858
59- $ this ->assertEquals ([
60- 'attribute ' => 'foo ' ,
61- 'operator ' => '= ' ,
62- 'value ' => 'bar ' ,
63- ], $ query ->toBase ()->filters ['and ' ][0 ]);
59+ $ this ->assertStringContainsString ('(foo=bar) ' , $ query ->toBase ()->getQuery ());
6460 }
6561
6662 public function test_scopes_are_applied_to_pagination_request ()
@@ -73,44 +69,36 @@ public function test_scopes_are_applied_to_pagination_request()
7369 ->expect (['search ' => []]);
7470
7571 $ this ->assertEmpty ($ query ->paginate ());
72+ $ this ->assertEmpty ($ query ->paginate ());
73+ $ this ->assertEmpty ($ query ->paginate ());
7674
77- $ this ->assertEquals ([
78- 'attribute ' => 'foo ' ,
79- 'operator ' => '= ' ,
80- 'value ' => 'bar ' ,
81- ], $ query ->toBase ()->filters ['and ' ][0 ]);
75+ $ this ->assertStringContainsString ('(foo=bar) ' , $ query ->toBase ()->getQuery ());
8276 }
8377
8478 public function test_scopes_are_not_stacked_multiple_times ()
8579 {
8680 $ query = ModelWithGlobalScopeTestStub::query ();
87- $ query ->getQuery ();
88- $ query ->getQuery ();
81+ // Call toBase() multiple times to verify scopes aren't stacked
82+ $ query ->toBase ();
83+ $ query ->toBase ();
8984
90- $ this ->assertCount (1 , $ query ->toBase ()->filters ['and ' ]);
91- $ this ->assertEquals ('(foo=bar) ' , $ query ->getQuery ()->getQuery ());
85+ $ this ->assertEquals ('(&(foo=bar)) ' , $ query ->toBase ()->getQuery ());
9286 }
9387
9488 public function test_local_scopes_can_be_called ()
9589 {
9690 $ query = ModelWithLocalScopeTestStub::fooBar ();
9791
9892 $ this ->assertInstanceOf (Builder::class, $ query );
99- $ this ->assertCount (1 , $ query ->toBase ()->filters ['and ' ]);
100- $ this ->assertEquals ('foo ' , $ query ->toBase ()->filters ['and ' ][0 ]['attribute ' ]);
101- $ this ->assertEquals ('= ' , $ query ->toBase ()->filters ['and ' ][0 ]['operator ' ]);
102- $ this ->assertEquals ('\62\61\72 ' , $ query ->toBase ()->filters ['and ' ][0 ]['value ' ]);
93+ $ this ->assertEquals ('(foo=\62\61\72) ' , $ query ->toBase ()->getQuery ());
10394 }
10495
10596 public function test_local_scopes_accept_arguments ()
10697 {
10798 $ query = ModelWithLocalScopeTestStub::barBaz ('zal ' );
10899
109100 $ this ->assertInstanceOf (Builder::class, $ query );
110- $ this ->assertCount (1 , $ query ->toBase ()->filters ['and ' ]);
111- $ this ->assertEquals ('bar ' , $ query ->toBase ()->filters ['and ' ][0 ]['attribute ' ]);
112- $ this ->assertEquals ('= ' , $ query ->toBase ()->filters ['and ' ][0 ]['operator ' ]);
113- $ this ->assertEquals ('\7a\61\6c ' , $ query ->toBase ()->filters ['and ' ][0 ]['value ' ]);
101+ $ this ->assertEquals ('(bar=\7a\61\6c) ' , $ query ->toBase ()->getQuery ());
114102 }
115103
116104 public function test_scopes_do_not_impact_model_refresh ()
0 commit comments