File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 33use Illuminate \Support \Facades \Config ;
44use Illuminate \Support \Facades \DB ;
55
6+ if (!function_exists ('db_is_sqlite ' )) {
7+ function db_is_sqlite ()
8+ {
9+ $ connection = DB ::getDefaultConnection ();
10+ $ driver = Config::get ("database.connections. {$ connection }.driver " );
11+
12+ return ($ driver == 'sqlite ' );
13+ }
14+ }
15+
616if (!function_exists ('db_is_mysql ' )) {
717 function db_is_mysql ()
818 {
Original file line number Diff line number Diff line change 1313class DbIsMysqlTest extends TestCase
1414{
1515 /** @test */
16- public function it_returns_true_if_laravel_database_default_connection_is_mysql ()
16+ public function it_returns_true_if_laravel_database_default_connection_driver_is_mysql ()
1717 {
1818 DB ::shouldReceive ('getDefaultConnection ' )->withNoArgs ()->once ()->andReturn ('mysql ' );
1919 Config::shouldReceive ('get ' )->with ("database.connections.mysql.driver " )->once ()->andReturn ('mysql ' );
@@ -22,7 +22,7 @@ public function it_returns_true_if_laravel_database_default_connection_is_mysql(
2222 }
2323
2424 /** @test */
25- public function it_returns_false_if_laravel_database_default_connection_is_not_mysql ()
25+ public function it_returns_false_if_laravel_database_default_connection_driver_is_not_mysql ()
2626 {
2727 DB ::shouldReceive ('getDefaultConnection ' )->withNoArgs ()->once ()->andReturn ('sqlite ' );
2828 Config::shouldReceive ('get ' )->with ("database.connections.sqlite.driver " )->once ()->andReturn ('sqlite ' );
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Illuminated \Helpers \HelperFunctions \Tests \Db ;
4+
5+ use Illuminate \Support \Facades \Config ;
6+ use Illuminate \Support \Facades \DB ;
7+ use Illuminated \Helpers \HelperFunctions \Tests \TestCase ;
8+
9+ /**
10+ * @runTestsInSeparateProcesses
11+ * @preserveGlobalState disabled
12+ */
13+ class DbIsSqliteTest extends TestCase
14+ {
15+ /** @test */
16+ public function it_returns_true_if_laravel_database_default_connection_driver_is_sqlite ()
17+ {
18+ DB ::shouldReceive ('getDefaultConnection ' )->withNoArgs ()->once ()->andReturn ('sqlite ' );
19+ Config::shouldReceive ('get ' )->with ("database.connections.sqlite.driver " )->once ()->andReturn ('sqlite ' );
20+
21+ $ this ->assertTrue (db_is_sqlite ());
22+ }
23+
24+ /** @test */
25+ public function it_returns_false_if_laravel_database_default_connection_driver_is_not_sqlite ()
26+ {
27+ DB ::shouldReceive ('getDefaultConnection ' )->withNoArgs ()->once ()->andReturn ('mysql ' );
28+ Config::shouldReceive ('get ' )->with ("database.connections.mysql.driver " )->once ()->andReturn ('mysql ' );
29+
30+ $ this ->assertFalse (db_is_sqlite ());
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments