1111
1212namespace WouterJ \EloquentBundle \DataCollector ;
1313
14+ use Illuminate \Container \Container ;
1415use Illuminate \Database \Capsule \Manager ;
16+ use Illuminate \Support \Fluent ;
1517use WouterJ \EloquentBundle \MockeryTrait ;
1618use Symfony \Component \HttpFoundation \Request ;
1719use Symfony \Component \HttpFoundation \Response ;
@@ -21,14 +23,18 @@ class EloquentDataCollectorTest extends TestCase
2123{
2224 use MockeryTrait;
2325
26+ private Container $ container ;
2427 private $ capsule ;
2528 private $ queryListener ;
2629 private $ collector ;
2730
2831 protected function setUp (): void
2932 {
33+ $ this ->container = new Container ();
34+ $ this ->container ->instance ('config ' , new Fluent (['database.connections ' => []]));
35+
3036 $ this ->capsule = \Mockery::mock (Manager::class);
31- $ this ->capsule ->allows ()->getContainer ()->andReturn ([ ' config ' => [ ' database.connections ' => []]])-> byDefault ( );
37+ $ this ->capsule ->allows ()->getContainer ()->andReturn ($ this -> container );
3238 $ this ->capsule ->allows ()->getDatabaseManager ()->andReturn (new class {
3339 public function getConnections () { return []; }
3440 })->byDefault ();
@@ -42,14 +48,10 @@ public function getConnections() { return []; }
4248 /** @test */
4349 public function it_collects_connections ()
4450 {
45- $ this ->capsule ->allows ()->getContainer ()->andReturn ([
46- 'config ' => [
47- 'database.connections ' => [
48- 'db1 ' => ['db ' => 'foobar ' ],
49- 'db2 ' => ['db ' => 'something else ' ]
50- ],
51- ],
52- ]);
51+ $ this ->container ['config ' ]['database.connections ' ] = [
52+ 'db1 ' => ['db ' => 'foobar ' ],
53+ 'db2 ' => ['db ' => 'something else ' ]
54+ ];
5355
5456 $ this ->capsule ->allows ()->getDatabaseManager ()->andReturn (new class {
5557 public function getConnections () {
0 commit comments