File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Mockery as m ;
4
+
5
+ class DbMysqlVariableTest extends TestCase
6
+ {
7
+ /** @test */
8
+ public function it_returns_false_for_unexisting_mysql_variable ()
9
+ {
10
+ $ mock = m::mock ('alias:Illuminate\Support\Facades\DB ' );
11
+ $ mock ->shouldReceive ('selectOne ' )
12
+ ->withArgs (['show variables where variable_name = ? ' , ['fake ' ]])
13
+ ->once ()
14
+ ->andReturnNull ()
15
+ ;
16
+ $ this ->assertFalse (db_mysql_variable ('fake ' ));
17
+ }
18
+
19
+ /** @test */
20
+ public function it_returns_value_for_known_mysql_variable ()
21
+ {
22
+ $ mock = m::mock ('alias:Illuminate\Support\Facades\DB ' );
23
+ $ mock ->shouldReceive ('selectOne ' )
24
+ ->withArgs (['show variables where variable_name = ? ' , ['hostname ' ]])
25
+ ->once ()
26
+ ->andReturnUsing (function () {
27
+ $ object = new StdClass ();
28
+ $ object ->Variable_name = 'hostname ' ;
29
+ $ object ->Value = 'localhost ' ;
30
+ return $ object ;
31
+ })
32
+ ;
33
+ $ this ->assertEquals ('localhost ' , db_mysql_variable ('hostname ' ));
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments