99
1010class CacheIntegrationTest extends TestCase
1111{
12+ protected $ defaultSetupConfig = [
13+ 'session.driver ' => 'array ' ,
14+ ];
15+
1216 public function testCacheBreadcrumbForWriteAndHitIsRecorded (): void
1317 {
1418 Cache::put ($ key = 'foo ' , 'bar ' );
@@ -53,10 +57,10 @@ public function testCacheBreadcrumbIsNotRecordedWhenDisabled(): void
5357
5458 public function testCacheBreadcrumbReplacesSessionKeyWithPlaceholder (): void
5559 {
56- // Start a session
57- $ this ->app [ ' request ' ]-> setLaravelSession ( $ session = $ this -> app [ ' session.store ' ]);
58- $ session -> start ();
59- $ sessionId = $ session ->getId ();
60+ // Start a session properly in the test environment
61+ $ this ->withSession ([ ' test ' => ' value ' ]);
62+
63+ $ sessionId = $ this -> app [ ' session ' ] ->getId ();
6064
6165 // Use the session ID as a cache key
6266 Cache::put ($ sessionId , 'session-data ' );
@@ -178,10 +182,10 @@ public function testCacheSpanReplacesSessionKeyWithPlaceholder(): void
178182 {
179183 $ this ->markSkippedIfTracingEventsNotAvailable ();
180184
181- // Start a session
182- $ this ->app [ ' request ' ]-> setLaravelSession ( $ session = $ this -> app [ ' session.store ' ]);
183- $ session -> start ();
184- $ sessionId = $ session ->getId ();
185+ // Start a session properly in the test environment
186+ $ this ->withSession ([ ' test ' => ' value ' ]);
187+
188+ $ sessionId = $ this -> app [ ' session ' ] ->getId ();
185189
186190 $ span = $ this ->executeAndReturnMostRecentSpan (function () use ($ sessionId ) {
187191 Cache::get ($ sessionId );
@@ -196,10 +200,10 @@ public function testCacheSpanReplacesMultipleSessionKeysWithPlaceholder(): void
196200 {
197201 $ this ->markSkippedIfTracingEventsNotAvailable ();
198202
199- // Start a session
200- $ this ->app [ ' request ' ]-> setLaravelSession ( $ session = $ this -> app [ ' session.store ' ]);
201- $ session -> start ();
202- $ sessionId = $ session ->getId ();
203+ // Start a session properly in the test environment
204+ $ this ->withSession ([ ' test ' => ' value ' ]);
205+
206+ $ sessionId = $ this -> app [ ' session ' ] ->getId ();
203207
204208 $ span = $ this ->executeAndReturnMostRecentSpan (function () use ($ sessionId ) {
205209 Cache::get ([$ sessionId , 'regular-key ' , $ sessionId . '_another ' ]);
@@ -214,15 +218,14 @@ public function testCacheOperationDoesNotStartSessionPrematurely(): void
214218 {
215219 $ this ->markSkippedIfTracingEventsNotAvailable ();
216220
217- // Make sure session is not started
218- $ this ->assertFalse ($ this ->app ['session.store ' ]->isStarted ());
221+ // Don't start a session to ensure it's not started
219222
220223 $ span = $ this ->executeAndReturnMostRecentSpan (function () {
221224 Cache::get ('some-key ' );
222225 });
223-
224- // Session should still not be started
225- $ this ->assertFalse ($ this ->app ['session.store ' ]->isStarted ());
226+
227+ // Check that session was not started
228+ $ this ->assertFalse ($ this ->app ['session ' ]->isStarted ());
226229
227230 // And the key should not be replaced
228231 $ this ->assertEquals ('some-key ' , $ span ->getDescription ());
0 commit comments