File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed
Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 11<?php
22
3+ use Illuminate \Support \Facades \Config ;
34use Illuminate \Support \Facades \DB ;
45
56if (!function_exists ('db_is_mysql ' )) {
67 function db_is_mysql ()
78 {
8- return (DB ::getDefaultConnection () == 'mysql ' );
9+ $ connection = DB ::getDefaultConnection ();
10+ $ driver = Config::get ("database.connections. {$ connection }.driver " );
11+
12+ return ($ driver == 'mysql ' );
913 }
1014}
1115
Original file line number Diff line number Diff line change 22
33namespace Illuminated \Helpers \HelperFunctions \Tests \Db ;
44
5+ use Illuminate \Support \Facades \Config ;
6+ use Illuminate \Support \Facades \DB ;
57use Illuminated \Helpers \HelperFunctions \Tests \TestCase ;
6- use Mockery ;
78
9+ /**
10+ * @runTestsInSeparateProcesses
11+ * @preserveGlobalState disabled
12+ */
813class DbIsMysqlTest extends TestCase
914{
1015 /** @test */
1116 public function it_returns_true_if_laravel_database_default_connection_is_mysql ()
1217 {
13- $ mock = Mockery:: mock ( ' alias:Illuminate\Support\Facades\DB ' );
14- $ mock -> shouldReceive ('getDefaultConnection ' )->withNoArgs ( )->once ()->andReturn ('mysql ' );
18+ DB :: shouldReceive ( ' getDefaultConnection ' )-> withNoArgs ()-> once ()-> andReturn ( ' mysql ' );
19+ Config:: shouldReceive ('get ' )->with ( " database.connections.mysql.driver " )->once ()->andReturn ('mysql ' );
1520
1621 $ this ->assertTrue (db_is_mysql ());
1722 }
1823
1924 /** @test */
2025 public function it_returns_false_if_laravel_database_default_connection_is_not_mysql ()
2126 {
22- $ mock = Mockery:: mock ( ' alias:Illuminate\Support\Facades\DB ' );
23- $ mock -> shouldReceive ('getDefaultConnection ' )->withNoArgs ( )->once ()->andReturn ('sqlite ' );
27+ DB :: shouldReceive ( ' getDefaultConnection ' )-> withNoArgs ()-> once ()-> andReturn ( ' sqlite ' );
28+ Config:: shouldReceive ('get ' )->with ( " database.connections.sqlite.driver " )->once ()->andReturn ('sqlite ' );
2429
2530 $ this ->assertFalse (db_is_mysql ());
2631 }
You can’t perform that action at this time.
0 commit comments