3 namespace Friendica\Test\Util;
5 use Mockery\MockInterface;
8 * Trait to mock the DBA connection status
13 * @var MockInterface The mocking interface of Friendica\Database\DBA
18 * Mocking DBA::connect()
20 * @param bool $return True, if the connect was successful, otherwise false
21 * @param null|int $times How often the method will get used
23 public function mockConnect($return = true, $times = null)
25 if (!isset($this->dbaMock)) {
26 $this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
30 ->shouldReceive('connect')
36 * Mocking DBA::connected()
38 * @param bool $return True, if the DB is connected, otherwise false
39 * @param null|int $times How often the method will get used
41 public function mockConnected($return = true, $times = null)
43 if (!isset($this->dbaMock)) {
44 $this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
48 ->shouldReceive('connected')
54 * Mocking DBA::fetchFirst()
56 * @param string $arg The argument of fetchFirst
57 * @param bool $return True, if the DB is connected, otherwise false
58 * @param null|int $times How often the method will get used
60 public function mockFetchFirst($arg, $return = true, $times = null)
62 if (!isset($this->dbaMock)) {
63 $this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
67 ->shouldReceive('fetchFirst')