]> git.mxchange.org Git - friendica.git/blob - tests/Util/DBStructureMockTrait.php
Bugfixing & Enhancement
[friendica.git] / tests / Util / DBStructureMockTrait.php
1 <?php
2
3 namespace Friendica\Test\Util;
4
5 /**
6  * Trait to mock the DBStructure connection status
7  */
8 trait DBStructureMockTrait
9 {
10         private $dbStructure;
11
12         public function mockUpdate($args = [], $return = true, $times = null)
13         {
14                 if (!isset($this->dbStructure)) {
15                         $this->dbStructure = \Mockery::mock('alias:Friendica\Database\DBStructure');
16                 }
17
18                 $this->dbStructure
19                         ->shouldReceive('update')
20                         ->withArgs($args)
21                         ->times($times)
22                         ->andReturn($return);
23         }
24
25         public function mockExistsTable($tableName, $return = true, $times = null)
26         {
27                 if (!isset($this->dbStructure)) {
28                         $this->dbStructure = \Mockery::mock('alias:Friendica\Database\DBStructure');
29                 }
30
31                 $this->dbStructure
32                         ->shouldReceive('existsTable')
33                         ->with($tableName)
34                         ->times($times)
35                         ->andReturn($return);
36         }
37 }