@@ -78,51 +78,18 @@ public function it_can_count_the_results()
7878    /** @test */ 
7979    public  function  it_respects_table_prefixes ()
8080    {
81-         $ connectionDB ::connection ();
82-         $ originalPrefix$ connectiongetTablePrefix ();
81+         $ this initDatabase ('prefix_ ' );
8382
84-         try  {
85-             // Set prefix FIRST before creating tables 
86-             $ connectionsetTablePrefix ('prefix_ ' );
87-             
88-             // Drop existing unprefixed tables 
89-             $ connectionsetTablePrefix ($ originalPrefix
90-             Schema::dropIfExists ('posts ' );
91-             Schema::dropIfExists ('videos ' );
92-             Schema::dropIfExists ('comments ' );
93-             Schema::dropIfExists ('blogs ' );
94-             Schema::dropIfExists ('pages ' );
95-             
96-             // Set prefix back and create prefixed tables 
97-             $ connectionsetTablePrefix ('prefix_ ' );
98-             include_once  __DIR__  . '/create_tables.php ' ;
99-             (new  \CreateTables )->up ();
100- 
101-             $ postAcreate (['title '  => 'foo ' ]);
102-             $ postBcreate (['title '  => 'bar ' ]);
103-             $ videoAcreate (['title '  => 'foo ' ]);
104-             $ videoBcreate (['title '  => 'bar ' , 'subtitle '  => 'foo ' ]);
105- 
106-             $ countadd (Post::class, 'title ' )
107-                 ->add (Video::class, ['title ' , 'subtitle ' ])
108-                 ->count ('foo ' );
109- 
110-             $ this assertEquals (3 , $ count
111-         } finally  {
112-             // Always reset prefix and recreate original tables 
113-             $ connectionsetTablePrefix ($ originalPrefix
114-             
115-             // Drop prefixed tables 
116-             Schema::dropIfExists ('prefix_posts ' );
117-             Schema::dropIfExists ('prefix_videos ' );
118-             Schema::dropIfExists ('prefix_comments ' );
119-             Schema::dropIfExists ('prefix_blogs ' );
120-             Schema::dropIfExists ('prefix_pages ' );
121-             
122-             // Recreate original tables for other tests 
123-             include_once  __DIR__  . '/create_tables.php ' ;
124-             (new  \CreateTables )->up ();
125-         }
83+         $ postAcreate (['title '  => 'foo ' ]);
84+         $ postBcreate (['title '  => 'bar ' ]);
85+         $ videoAcreate (['title '  => 'foo ' ]);
86+         $ videoBcreate (['title '  => 'bar ' , 'subtitle '  => 'foo ' ]);
87+ 
88+         $ countadd (Post::class, 'title ' )
89+             ->add (Video::class, ['title ' , 'subtitle ' ])
90+             ->count ('foo ' );
91+ 
92+         $ this assertEquals (3 , $ count
12693    }
12794
12895    /** @test */ 
0 commit comments