Browse Source

Cleanup tests

- Remove DBAMockTrait
- Remove DBStructureMockTrait
pull/10891/head
Philipp 7 months ago
parent
commit
ef1e2ce77e
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
  1. 354
      tests/Util/DBAMockTrait.php
  2. 77
      tests/Util/DBStructureMockTrait.php
  3. 56
      tests/src/App/ModeTest.php
  4. 4
      tests/src/Console/AutomaticInstallationConsoleTest.php
  5. 123
      tests/src/Model/UserTest.php

354
tests/Util/DBAMockTrait.php

@ -1,354 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Test\Util;
use Friendica\Database\DBA;
use Mockery\MockInterface;
class DBAStub
{
public static $connected = true;
}
/**
* Trait to mock the DBA connection status
*/
trait DBAMockTrait
{
/**
* @var MockInterface The mocking interface of Friendica\Database\DBA
*/
private $dbaMock;
private function checkMock()
{
if (!isset($this->dbaMock)) {
$this->dbaMock = \Mockery::namedMock(DBA::class, DBAStub::class);
}
}
/**
* Mocking DBA::connect()
*
* @param bool $return True, if the connect was successful, otherwise false
* @param null|int $times How often the method will get used
*/
public function mockConnect($return = true, $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('connect')
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::connected()
*
* @param bool $return True, if the DB is connected, otherwise false
* @param null|int $times How often the method will get used
*/
public function mockConnected($return = true, $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('connected')
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::fetchFirst()
*
* @param string $arg The argument of fetchFirst
* @param bool $return True, if the DB is connected, otherwise false
* @param null|int $times How often the method will get used
*/
public function mockFetchFirst(string $arg, bool $return = true, int $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('fetchFirst')
->with($arg)
->times($times)
->andReturn($return);
}
/**
* Mocking each DBA::fetch() call of an statement
*
* @param array $stmt The result statement (array)
* @param null|int $times How often the method will get used
*/
public function mockFetchLoop($stmt = [], $times = null)
{
$this->checkMock();
foreach ($stmt as $item) {
$this->dbaMock
->shouldReceive('fetch')
->times($times)
->andReturn($item);
}
// The last mock call of a fetch (=> breaking the loop)
$this->dbaMock
->shouldReceive('fetch')
->times($times)
->andReturn(false);
}
/**
* Mocking DBA::close()
*
* @param array $return The return per fetch
* @param null|int $times How often the method will get used
*/
public function mockDbaClose($return = [], $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('close')
->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(string $tableName, array $select = [], array $where = [], $return = null, int $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('select')
->with($tableName, $select, $where)
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::delete()
*
* @param string $tableName The name of the table
* @param array $where The Where Array (Default is [])
* @param bool $return The array to return (Default is true)
* @param null|int $times How often the method will get used
*/
public function mockDBADelete(string $tableName, array $where = [], bool $return = true, int $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('delete')
->with($tableName, $where)
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::update()
*
* @param string $expTableName The name of the table
* @param array $expFields The Fields Array
* @param array $expCondition The Condition Array
* @param array $expOld_fields The Old Fieldnames (Default is [])
* @param bool $return true if the update was successful
* @param null|int $times How often the method will get used
*/
public function mockDBAUpdate(string $expTableName, array $expFields, array $expCondition, array $expOld_fields = [], bool $return = true, int $times = null)
{
$this->checkMock();
$closure = function ($tableName, $fields, $condition, $old_fields = []) use ($expTableName, $expFields, $expCondition, $expOld_fields) {
return
$tableName == $expTableName &&
$fields == $expFields &&
$condition == $expCondition &&
$old_fields == $expOld_fields;
};
$this->dbaMock
->shouldReceive('update')
->withArgs($closure)
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::insert()
*
* @param string $expTableName The name of the table
* @param array $expParam The Parameters Array
* @param bool $expOnDuplUpdate Update on a duplicated entry
* @param bool $return True if the insert was successful
* @param null|int $times How often the method will get used
*/
public function mockDBAInsert(string $expTableName, array $expParam, bool $expOnDuplUpdate = false, bool $return = true, int $times = null)
{
$this->checkMock();
$closure = function ($tableName, $param, $on_duplicate_update = false) use ($expTableName, $expParam, $expOnDuplUpdate) {
return $tableName == $expTableName
&& $param == $expParam
&& $on_duplicate_update == $expOnDuplUpdate;
};
$this->dbaMock
->shouldReceive('insert')
->withArgs($closure)
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::selectFirst()
*
* @param string $expTableName The name of the table
* @param array $expSelect The Select Array (Default is [])
* @param array $expWhere 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(string $expTableName, array $expSelect = [], array $expWhere = [], array $return = [], int $times = null)
{
$this->checkMock();
$closure = function ($tableName, $select = [], $where = []) use ($expTableName, $expSelect, $expWhere) {
return $tableName === $expTableName
&& $select === $expSelect
&& $where === $expWhere;
};
$this->dbaMock
->shouldReceive('selectFirst')
->withArgs($closure)
->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)
{
$this->checkMock();
$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)
{
$this->checkMock();
$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)
{
$this->checkMock();
if (!isset($sql)) {
$this->dbaMock
->shouldReceive('p')
->times($times)
->andReturn($return);
} else {
$this->dbaMock
->shouldReceive('p')
->with($sql)
->times($times)
->andReturn($return);
}
}
/**
* Mocking DBA::lock()
*
* @param string $table The table to lock
* @param bool $return True, if the lock is set successful
* @param null|int $times How often the method will get used
*/
public function mockDbaLock(string $table, bool $return = true, int $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('lock')
->with($table)
->times($times)
->andReturn($return);
}
/**
* Mocking DBA::unlock()
*
* @param bool $return True, if the lock is set successful
* @param null|int $times How often the method will get used
*/
public function mockDbaUnlock( $return = true, $times = null)
{
$this->checkMock();
$this->dbaMock
->shouldReceive('unlock')
->times($times)
->andReturn($return);
}
}

77
tests/Util/DBStructureMockTrait.php

@ -1,77 +0,0 @@
<?php
/**
* @copyright Copyright (C) 2010-2021, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
namespace Friendica\Test\Util;
use Friendica\Database\DBStructure;
use Mockery\MockInterface;
/**
* Trait to mock the DBStructure connection status
*/
trait DBStructureMockTrait
{
/**
* @var MockInterface The mocking interface of Friendica\Database\DBStructure
*/
private $dbStructure;
/**
* Mocking DBStructure::update()
* @see DBStructure::update();
*
* @param array $args The arguments for the update call
* @param bool $return True, if the connect was successful, otherwise false
* @param null|int $times How often the method will get used
*/
public function mockUpdate(array $args = [], bool $return = true, int $times = null)
{
if (!isset($this->dbStructure)) {
$this->dbStructure = \Mockery::mock('alias:' . DBStructure::class);
}
$this->dbStructure
->shouldReceive('update')
->withArgs($args)
->times($times)
->andReturn($return);
}
/**
* Mocking DBStructure::existsTable()
*
* @param string $tableName The name of the table to check
* @param bool $return True, if the connect was successful, otherwise false
* @param null|int $times How often the method will get used
*/
public function mockExistsTable(string $tableName, bool $return = true, int $times = null)
{
if (!isset($this->dbStructure)) {
$this->dbStructure = \Mockery::mock('alias:' . DBStructure::class);
}
$this->dbStructure
->shouldReceive('existsTable')
->with($tableName)
->times($times)
->andReturn($return);
}
}

56
tests/src/App/ModeTest.php

@ -27,7 +27,6 @@ use Friendica\App\Module;
use Friendica\Core\Config\Cache;
use Friendica\Database\Database;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\BasePath;
use Mockery;
@ -36,7 +35,6 @@ use Mockery\MockInterface;
class ModeTest extends MockedTest
{
use VFSTrait;
use DBAMockTrait;
/**
* @var BasePath|MockInterface
@ -53,14 +51,14 @@ class ModeTest extends MockedTest
*/
private $configCacheMock;
protected function setUp() : void
protected function setUp(): void
{
parent::setUp();
$this->setUpVfsDir();
$this->basePathMock = Mockery::mock(BasePath::class);
$this->databaseMock = Mockery::mock(Database::class);
$this->basePathMock = Mockery::mock(BasePath::class);
$this->databaseMock = Mockery::mock(Database::class);
$this->configCacheMock = Mockery::mock(Cache::class);
}
@ -110,7 +108,7 @@ class ModeTest extends MockedTest
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
$this->databaseMock->shouldReceive('fetchFirst')
->with('SHOW TABLES LIKE \'config\'')->andReturn(false)->once();
->with('SHOW TABLES LIKE \'config\'')->andReturn(false)->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
@ -126,9 +124,9 @@ class ModeTest extends MockedTest
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
$this->databaseMock->shouldReceive('fetchFirst')
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(true)->once();
->andReturn(true)->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
@ -145,12 +143,12 @@ class ModeTest extends MockedTest
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
$this->databaseMock->shouldReceive('fetchFirst')
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(false)->once();
->andReturn(false)->once();
$this->databaseMock->shouldReceive('selectFirst')
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
->andReturn(['v' => null])->once();
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
->andReturn(['v' => null])->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
@ -170,12 +168,12 @@ class ModeTest extends MockedTest
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
$this->databaseMock->shouldReceive('fetchFirst')
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(false)->once();
->andReturn(false)->once();
$this->databaseMock->shouldReceive('selectFirst')
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
->andReturn(['v' => '0'])->once();
->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
->andReturn(['v' => '0'])->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
@ -205,8 +203,8 @@ class ModeTest extends MockedTest
*/
public function testIsBackendNotIsBackend()
{
$server = [];
$module = new Module();
$server = [];
$module = new Module();
$mobileDetect = new MobileDetect();
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
@ -219,8 +217,8 @@ class ModeTest extends MockedTest
*/
public function testIsBackendButIndex()
{
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], true);
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], true);
$mobileDetect = new MobileDetect();
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
@ -233,8 +231,8 @@ class ModeTest extends MockedTest
*/
public function testIsNotBackend()
{
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$mobileDetect = new MobileDetect();
$mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
@ -252,7 +250,7 @@ class ModeTest extends MockedTest
'HTTP_X_REQUESTED_WITH' => 'xmlhttprequest',
];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$mobileDetect = new MobileDetect();
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
@ -265,8 +263,8 @@ class ModeTest extends MockedTest
*/
public function testIsNotAjax()
{
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$mobileDetect = new MobileDetect();
$mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
@ -279,8 +277,8 @@ class ModeTest extends MockedTest
*/
public function testIsMobileIsTablet()
{
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$mobileDetect = Mockery::mock(MobileDetect::class);
$mobileDetect->shouldReceive('isMobile')->andReturn(true);
$mobileDetect->shouldReceive('isTablet')->andReturn(true);
@ -297,8 +295,8 @@ class ModeTest extends MockedTest
*/
public function testIsNotMobileIsNotTablet()
{
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$server = [];
$module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
$mobileDetect = Mockery::mock(MobileDetect::class);
$mobileDetect->shouldReceive('isMobile')->andReturn(false);
$mobileDetect->shouldReceive('isTablet')->andReturn(false);

4
tests/src/Console/AutomaticInstallationConsoleTest.php

@ -30,8 +30,6 @@ use Friendica\Core\L10n;
use Friendica\Core\Logger;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\DBStructureMockTrait;
use Friendica\Test\Util\RendererMockTrait;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\Logger\VoidLogger;
@ -43,8 +41,6 @@ use org\bovigo\vfs\vfsStreamFile;
class AutomaticInstallationConsoleTest extends ConsoleTest
{
use VFSTrait;
use DBAMockTrait;
use DBStructureMockTrait;
use RendererMockTrait;
/**

123
tests/src/Model/UserTest.php

@ -21,54 +21,58 @@
namespace Friendica\Test\src\Model;
use Dice\Dice;
use Friendica\Database\Database;
use Friendica\DI;
use Friendica\Model\User;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\DBAMockTrait;
use Mockery\MockInterface;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class UserTest extends MockedTest
{
use DBAMockTrait;
private $parent;
private $child;
private $manage;
/** @var Database|MockInterface */
private $dbMock;
protected function setUp(): void
{
parent::setUp();
$this->dbMock = \Mockery::mock(Database::class);
$diceMock = \Mockery::mock(Dice::class)->makePartial();
/** @var Dice|MockInterface $diceMock */
$diceMock = $diceMock->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
$diceMock->shouldReceive('create')->withArgs([Database::class])->andReturn($this->dbMock);
DI::init($diceMock);
$this->parent = [
'uid' => 1,
'username' => 'maxmuster',
'nickname' => 'Max Muster'
'uid' => 1,
'username' => 'maxmuster',
'nickname' => 'Max Muster'
];
$this->child = [
'uid' => 2,
'username' => 'johndoe',
'nickname' => 'John Doe'
'uid' => 2,
'username' => 'johndoe',
'nickname' => 'John Doe'
];
$this->manage = [
'uid' => 3,
'username' => 'janesmith',
'nickname' => 'Jane Smith'
'uid' => 3,
'username' => 'janesmith',
'nickname' => 'Jane Smith'
];
}
public function testIdentitiesEmpty()
{
$this->mockSelectFirst('user',
['uid', 'nickname', 'username', 'parent-uid'],
['uid' => $this->parent['uid']],
$this->parent,
1
);
$this->mockIsResult($this->parent, false, 1);
$this->dbMock->shouldReceive('selectFirst')->with('user',
['uid', 'nickname', 'username', 'parent-uid'],['uid' => $this->parent['uid']], [])->andReturn($this->parent)->once();
$this->dbMock->shouldReceive('isResult')->with($this->parent)->andReturn(false)->once();
$record = User::identities($this->parent['uid']);
@ -77,35 +81,28 @@ class UserTest extends MockedTest
public function testIdentitiesAsParent()
{
$parentSelect = $this->parent;
$parentSelect = $this->parent;
$parentSelect['parent-uid'] = 0;
// Select the user itself (=parent)
$this->mockSelectFirst('user',
['uid', 'nickname', 'username', 'parent-uid'],
['uid' => $this->parent['uid']],
$parentSelect,
1
);
$this->mockIsResult($parentSelect, true, 1);
$this->dbMock->shouldReceive('selectFirst')->with('user',
['uid', 'nickname', 'username', 'parent-uid'],['uid' => $this->parent['uid']], [])->andReturn($parentSelect)->once();
$this->dbMock->shouldReceive('isResult')->with($parentSelect)->andReturn(true)->once();
// Select one child
$this->mockSelect('user',
$this->dbMock->shouldReceive('select')->with('user',
['uid', 'username', 'nickname'],
[
'parent-uid' => $this->parent['uid'],
'parent-uid' => $this->parent['uid'],
'account_removed' => false
],
'objectReturn',
1
);
$this->mockIsResult('objectReturn', true, 1);
$this->mockToArray('objectReturn', [ $this->child ], 1);
], [])->andReturn('objectReturn')->once();
$this->dbMock->shouldReceive('isResult')->with('objectReturn')->andReturn(true)->once();
$this->dbMock->shouldReceive('toArray')->with('objectReturn', true, 0)->andReturn([$this->child])->once();
// Select the manage
$this->mockP(null, 'objectTwo', 1);
$this->mockIsResult('objectTwo', true, 1);
$this->mockToArray('objectTwo', [ $this->manage ], 1);
$this->dbMock->shouldReceive('p')->withAnyArgs()->andReturn('objectTwo')->once();
$this->dbMock->shouldReceive('isResult')->with('objectTwo')->andReturn(true)->once();
$this->dbMock->shouldReceive('toArray')->with('objectTwo', true, 0)->andReturn([$this->manage])->once();
$record = User::identities($this->parent['uid']);
@ -118,47 +115,37 @@ class UserTest extends MockedTest
public function testIdentitiesAsChild()
{
$childSelect = $this->child;
$childSelect = $this->child;
$childSelect['parent-uid'] = $this->parent['uid'];
// Select the user itself (=child)
$this->mockSelectFirst('user',
['uid', 'nickname', 'username', 'parent-uid'],
['uid' => $this->child['uid']],
$childSelect,
1
);
$this->mockIsResult($childSelect, true, 1);
$this->dbMock->shouldReceive('selectFirst')->with('user',
['uid', 'nickname', 'username', 'parent-uid'],['uid' => $this->child['uid']], [])->andReturn($childSelect)->once();
$this->dbMock->shouldReceive('isResult')->with($childSelect)->andReturn(true)->once();
// Select the parent
$this->mockSelect('user',
$this->dbMock->shouldReceive('select')->with('user',
['uid', 'username', 'nickname'],
[
'uid' => $this->parent['uid'],
'uid' => $this->parent['uid'],
'account_removed' => false
],
'objectReturn',
1
);
$this->mockIsResult('objectReturn', true, 1);
$this->mockToArray('objectReturn', [ $this->parent ], 1);
], [])->andReturn('objectReturn')->once();
$this->dbMock->shouldReceive('isResult')->with('objectReturn')->andReturn(true)->once();
$this->dbMock->shouldReceive('toArray')->with('objectReturn', true, 0)->andReturn([$this->parent])->once();
// Select the childs (user & manage)
$this->mockSelect('user',
$this->dbMock->shouldReceive('select')->with('user',
['uid', 'username', 'nickname'],
[
'parent-uid' => $this->parent['uid'],
'parent-uid' => $this->parent['uid'],
'account_removed' => false
],
'objectReturn',
1
);
$this->mockIsResult('objectReturn', true, 1);
$this->mockToArray('objectReturn', [ $this->child, $this->manage ], 1);
], [])->andReturn('objectReturn')->once();
$this->dbMock->shouldReceive('isResult')->with('objectReturn')->andReturn(true)->once();
$this->dbMock->shouldReceive('toArray')->with('objectReturn', true, 0)->andReturn([$this->child, $this->manage])->once();
// Select the manage
$this->mockP(null, 'objectTwo', 1);
$this->mockIsResult('objectTwo', false, 1);
$this->dbMock->shouldReceive('p')->withAnyArgs()->andReturn('objectTwo')->once();
$this->dbMock->shouldReceive('isResult')->with('objectTwo')->andReturn(false)->once();
$record = User::identities($this->child['uid']);

Loading…
Cancel
Save