mirror of
https://git.friendi.ca/friendica/friendica.git
synced 2025-06-17 03:25:15 +02:00
Refactoring identities to Model\User::identities
This commit is contained in:
parent
27dd913fcc
commit
8ad721988b
4 changed files with 337 additions and 44 deletions
|
@ -69,4 +69,117 @@ trait DBAMockTrait
|
|||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mocking DBA::select()
|
||||
*
|
||||
* @param string $tableName The name of the table
|
||||
* @param array $select The Select Array (Default is [])
|
||||
* @param array $where The Where Array (Default is [])
|
||||
* @param object $return The array to return (Default is [])
|
||||
* @param null|int $times How often the method will get used
|
||||
*/
|
||||
public function mockSelect($tableName, $select = [], $where = [], $return = null, $times = null)
|
||||
{
|
||||
if (!isset($this->dbaMock)) {
|
||||
$this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
|
||||
}
|
||||
|
||||
$this->dbaMock
|
||||
->shouldReceive('select')
|
||||
->with($tableName, $select, $where)
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocking DBA::selectFirst()
|
||||
*
|
||||
* @param string $tableName The name of the table
|
||||
* @param array $select The Select Array (Default is [])
|
||||
* @param array $where The Where Array (Default is [])
|
||||
* @param array $return The array to return (Default is [])
|
||||
* @param null|int $times How often the method will get used
|
||||
*/
|
||||
public function mockSelectFirst($tableName, $select = [], $where = [], $return = [], $times = null)
|
||||
{
|
||||
if (!isset($this->dbaMock)) {
|
||||
$this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
|
||||
}
|
||||
|
||||
$this->dbaMock
|
||||
->shouldReceive('selectFirst')
|
||||
->with($tableName, $select, $where)
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocking DBA::isResult()
|
||||
*
|
||||
* @param object $record The record to test
|
||||
* @param bool $return True, if the DB is connected, otherwise false
|
||||
* @param null|int $times How often the method will get used
|
||||
*/
|
||||
public function mockIsResult($record, $return = true, $times = null)
|
||||
{
|
||||
if (!isset($this->dbaMock)) {
|
||||
$this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
|
||||
}
|
||||
|
||||
$this->dbaMock
|
||||
->shouldReceive('isResult')
|
||||
->with($record)
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mocking DBA::isResult()
|
||||
*
|
||||
* @param object $record The record to test
|
||||
* @param array $return The array to return
|
||||
* @param null|int $times How often the method will get used
|
||||
*/
|
||||
public function mockToArray($record = null, $return = [], $times = null)
|
||||
{
|
||||
if (!isset($this->dbaMock)) {
|
||||
$this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
|
||||
}
|
||||
|
||||
$this->dbaMock
|
||||
->shouldReceive('toArray')
|
||||
->with($record)
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Mocking DBA::p()
|
||||
*
|
||||
* @param string $sql The SQL statement
|
||||
* @param object $return The object to return
|
||||
* @param null|int $times How often the method will get used
|
||||
*/
|
||||
public function mockP($sql = null, $return = null, $times = null)
|
||||
{
|
||||
if (!isset($this->dbaMock)) {
|
||||
$this->dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
|
||||
}
|
||||
|
||||
if (!isset($sql)) {
|
||||
$this->dbaMock
|
||||
->shouldReceive('p')
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
} else {
|
||||
$this->dbaMock
|
||||
->shouldReceive('p')
|
||||
->with($sql)
|
||||
->times($times)
|
||||
->andReturn($return);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue