mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 21:43:22 +09:00
68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace Box\Mod\Example\Api;
|
|
|
|
|
|
class ClientTest extends \BBTestCase {
|
|
|
|
/**
|
|
* @var \Box\Mod\Example\Api\Client
|
|
*/
|
|
protected $api = null;
|
|
|
|
public function setup()
|
|
{
|
|
$this->api= new \Box\Mod\Example\Api\Client();
|
|
}
|
|
|
|
public function testget_info()
|
|
{
|
|
$data = array('microsoft');
|
|
|
|
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
|
|
$eventMock->expects($this->atLeastOnce())->method('fire');
|
|
|
|
$modelClient = new \Model_Client();
|
|
$modelClient->loadBean(new \RedBeanPHP\OODBBean());
|
|
|
|
$clientService = $this->getMockBuilder('\Box\Mod\Client\Service')->getMock();
|
|
$clientService->expects($this->atLeastOnce())
|
|
->method('toApiArray')
|
|
->with($modelClient)
|
|
->willReturn(array());
|
|
|
|
$systemService = $this->getMockBuilder('\Box\Mod\System\Service')->getMock();
|
|
$systemService->expects($this->atLeastOnce())
|
|
->method('getVersion')
|
|
->willReturn(\Box_Version::VERSION);
|
|
$systemService->expects($this->atLeastOnce())
|
|
->method('getMessages')
|
|
->willReturn(array());
|
|
|
|
$di = new \Box_Di();
|
|
$di['logger'] = new \Box_Log();
|
|
$di['events_manager'] = $eventMock;
|
|
$di['mod_service'] = $di->protect(function ($serviceName) use ($clientService, $systemService){
|
|
if ($serviceName == 'Client'){
|
|
return $clientService;
|
|
}
|
|
if ($serviceName == 'System'){
|
|
return $systemService;
|
|
}
|
|
return -1;
|
|
});
|
|
$di['loggedin_client'] = $modelClient;
|
|
$di['array_get'] = $di->protect(function (array $array, $key, $default = null) use ($di) {
|
|
return isset ($array[$key]) ? $array[$key] : $default;
|
|
});
|
|
$this->api->setDi($di);
|
|
|
|
$result = $this->api->get_info($data);
|
|
$this->assertInternalType('array', $result);
|
|
$this->assertArrayHasKey('version', $result);
|
|
$this->assertArrayHasKey('profile', $result);
|
|
$this->assertArrayHasKey('messages', $result);
|
|
}
|
|
}
|
|
|