コード例 #1
0
ファイル: AdminTest.php プロジェクト: Ryan-Nolan/boxbilling
 public function test_log_get_list_ItemUserClient()
 {
     $simpleResultArr = array('list' => array(array('id' => 1, 'client_id' => 1, 'client_name' => 'Joe', 'client_email' => '*****@*****.**')));
     $paginatorMock = $this->getMockBuilder('\\Box_Pagination')->disableOriginalConstructor()->getMock();
     $paginatorMock->expects($this->atLeastOnce())->method('getSimpleResultSet')->will($this->returnValue($simpleResultArr));
     $service = $this->getMockBuilder('\\Box\\Mod\\Activity\\Service')->getMock();
     $service->expects($this->atLeastOnce())->method('getSearchQuery')->will($this->returnValue('String'));
     $model = new \Model_ActivitySystem();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $di = new \Box_Di();
     $di['pager'] = $paginatorMock;
     $di['mod_service'] = $di->protect(function () use($service) {
         return $service;
     });
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $api = new \Api_Handler(new \Model_Admin());
     $api->setDi($di);
     $di['api_admin'] = $api;
     $activity = new \Box\Mod\Activity\Api\Admin();
     $activity->setDi($di);
     $activity->setService($service);
     $activity->log_get_list(array());
 }
コード例 #2
0
ファイル: ServiceTest.php プロジェクト: Ryan-Nolan/boxbilling
 /**
  * @dataProvider testSendTemplateExistsStaffProvider
  */
 public function testSendTemplateExistsStaff($data, $clientGetExpects, $staffgetListExpects)
 {
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Email\\Service')->setMethods(array('sendMail'))->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('sendMail')->willReturn(true);
     $di = new \Box_Di();
     $emailTemplate = new \Model_EmailTemplate();
     $emailTemplate->loadBean(new \RedBeanPHP\OODBBean());
     $db = $this->getMockBuilder('Box_Database')->getMock();
     $db->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($emailTemplate));
     $db->expects($this->atLeastOnce())->method('store')->will($this->returnValue(1));
     $system = $this->getMockBuilder('Box\\Mod\\System\\Service')->getMock();
     $system->expects($this->atLeastOnce())->method('getParamValue')->will($this->returnValue('value'));
     $staffServiceMock = $this->getMockBuilder('Box\\Mod\\Staff\\Service')->getMock();
     $staffServiceMock->expects($staffgetListExpects)->method('getList')->will($this->returnValue(array('list' => array(0 => array('id' => 1, 'email' => '*****@*****.**', 'name' => 'George')))));
     $clientServiceMock = $this->getMockBuilder('Box\\Mod\\Client\\Service')->getMock();
     $clientModel = new \Model_Client();
     $clientModel->loadBean(new \RedBeanPHP\OODBBean());
     $clientServiceMock->expects($clientGetExpects)->method('get')->will($this->returnValue($clientModel));
     $clientApiArray = array('id' => 1, 'email' => '*****@*****.**', 'first_name' => 'John', 'last_name' => 'Smith');
     $clientServiceMock->expects($clientGetExpects)->method('toApiArray')->will($this->returnValue($clientApiArray));
     $twig = $this->getMockBuilder('Twig_Environment')->getMock();
     $twig->expects($this->atLeastOnce())->method('render')->will($this->returnValue('value'));
     $cryptMock = $this->getMockBuilder('\\Box_Crypt')->disableOriginalConstructor()->getMock();
     $cryptMock->expects($this->atLeastOnce())->method('encrypt');
     $di['api_admin'] = function () use($di) {
         $api = new \Api_Handler(new \Model_Admin());
         $api->setDi($di);
         return $api;
     };
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->disableOriginalConstructor()->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray')->will($this->returnValue(null));
     $di['validator'] = $validatorMock;
     $di['db'] = $db;
     $di['twig'] = $twig;
     $di['crypt'] = $cryptMock;
     $di['mod_service'] = $di->protect(function ($name) use($system, $staffServiceMock, $clientServiceMock) {
         if ($name == 'staff') {
             return $staffServiceMock;
         } elseif ($name == 'system') {
             return $system;
         } elseif ($name == 'client') {
             return $clientServiceMock;
         }
     });
     $di['tools'] = new \Box_Tools();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $serviceMock->setDi($di);
     $result = $serviceMock->sendTemplate($data);
     $this->assertTrue($result);
 }
コード例 #3
0
ファイル: bb-di.php プロジェクト: Ryan-Nolan/boxbilling
        case 'guest':
            $identity = new \Model_Guest();
            break;
        case 'client':
            $identity = $di['loggedin_client'];
            break;
        case 'admin':
            $identity = $di['loggedin_admin'];
            break;
        case 'system':
            $identity = $di['mod_service']('staff')->getCronAdmin();
            break;
        default:
            throw new Exception('Unrecognized Handler type: ' . $role);
    }
    $api = new Api_Handler($identity);
    $api->setDi($di);
    return $api;
});
$di['api_guest'] = function () use($di) {
    return $di['api']('guest');
};
$di['api_client'] = function () use($di) {
    return $di['api']('client');
};
$di['api_admin'] = function () use($di) {
    return $di['api']('admin');
};
$di['api_system'] = function () use($di) {
    return $di['api']('system');
};