• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Box_Di类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Box_Di的典型用法代码示例。如果您正苦于以下问题:PHP Box_Di类的具体用法?PHP Box_Di怎么用?PHP Box_Di使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Box_Di类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testdeductFunds

 public function testdeductFunds()
 {
     $di = new \Box_Di();
     $clientBalance = new \Model_ClientBalance();
     $clientBalance->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('dispense')->with('ClientBalance')->willReturn($clientBalance);
     $dbMock->expects($this->atLeastOnce())->method('store')->with($clientBalance);
     $di['db'] = $dbMock;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $service = new \Box\Mod\Client\ServiceBalance();
     $service->setDi($di);
     $clientModel = new \Model_Client();
     $clientModel->loadBean(new \RedBeanPHP\OODBBean());
     $description = 'Charged for product';
     $amount = 5.55;
     $extra = array('rel_id' => 1);
     $result = $service->deductFunds($clientModel, $amount, $description, $extra);
     $this->assertInstanceOf('\\Model_ClientBalance', $result);
     $this->assertEquals(-$amount, $result->amount);
     $this->assertEquals($description, $result->description);
     $this->assertEquals($extra['rel_id'], $result->rel_id);
     $this->assertEquals('default', $result->type);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:26,代码来源:ServiceBalanceTest.php


示例2: testTicket_get_list

 public function testTicket_get_list()
 {
     $simpleResultArr = array('list' => array(array('id' => 1)));
     $paginatorMock = $this->getMockBuilder('\\Box_Pagination')->disableOriginalConstructor()->getMock();
     $paginatorMock->expects($this->atLeastOnce())->method('getAdvancedResultSet')->will($this->returnValue($simpleResultArr));
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Support\\Service')->setMethods(array('getSearchQuery', 'toApiArray'))->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('getSearchQuery')->will($this->returnValue(array('query', array())));
     $serviceMock->expects($this->atLeastOnce())->method('toApiArray')->will($this->returnValue(array()));
     $model = new \Model_SupportTicket();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->will($this->returnValue($model));
     $di = new \Box_Di();
     $di['pager'] = $paginatorMock;
     $di['db'] = $dbMock;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->clientApi->setDi($di);
     $client = new \Model_Client();
     $client->loadBean(new \RedBeanPHP\OODBBean());
     $client->id = rand(1, 100);
     $this->clientApi->setService($serviceMock);
     $this->clientApi->setIdentity($client);
     $data = array();
     $result = $this->clientApi->ticket_get_list($data);
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:28,代码来源:Api_ClientTest.php


示例3: testget_info

 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);
 }
开发者ID:krynomore,项目名称:boxbilling,代码行数:35,代码来源:ClientTest.php


示例4: testGet_list

 public function testGet_list()
 {
     $clientApi = new \Box\Mod\Email\Api\Client();
     $emailService = new \Box\Mod\Email\Service();
     $willReturn = array("list" => array('id' => 1));
     $pager = $this->getMockBuilder('Box_Pagination')->getMock();
     $pager->expects($this->atLeastOnce())->method('getSimpleResultSet')->will($this->returnValue($willReturn));
     $di = new \Box_Di();
     $di['pager'] = $pager;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $clientApi->setDi($di);
     $emailService->setDi($di);
     $service = $emailService;
     $clientApi->setService($service);
     $client = new \Model_Client();
     $client->loadBean(new \RedBeanPHP\OODBBean());
     $client->id = rand(1, 100);
     $clientApi->setIdentity($client);
     $result = $clientApi->get_list(array());
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('list', $result);
     $this->assertInternalType('array', $result['list']);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:25,代码来源:Api_ClientTest.php


示例5: testEvents

 public function testEvents()
 {
     $di = new \Box_Di();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->service->setDi($di);
     $result = $this->service->getSearchQuery(array());
     $this->assertInternalType('array', $result);
 }
开发者ID:krynomore,项目名称:boxbilling,代码行数:10,代码来源:ServiceTest.php


示例6: testlanguages

 public function testlanguages()
 {
     $systemServiceMock = $this->getMockBuilder('\\Box\\Mod\\System\\Service')->getMock();
     $systemServiceMock->expects($this->atLeastOnce())->method('getLanguages')->will($this->returnValue(array()));
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function ($name) use($systemServiceMock) {
         return $systemServiceMock;
     });
     $this->api->setDi($di);
     $result = $this->api->languages();
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:12,代码来源:GuestTest.php


示例7: testbatch_connect

 public function testbatch_connect()
 {
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Hook\\Service')->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('batchConnect')->will($this->returnValue(1));
     $di = new \Box_Di();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->api->setDi($di);
     $this->api->setService($serviceMock);
     $result = $this->api->batch_connect(array());
     $this->assertNotEmpty($result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:13,代码来源:AdminTest.php


示例8: testrecaptcha

 /**
  * @dataProvider datarecaptchaConfig
  */
 public function testrecaptcha($config, $expected)
 {
     $di = new \Box_Di();
     $di['mod_config'] = $di->protect(function () use($config) {
         return $config;
     });
     $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->recaptcha(array());
     $this->assertEquals($expected, $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:16,代码来源:GuestTest.php


示例9: testgetPairs

 public function testgetPairs()
 {
     $service = new \Box\Mod\Page\Service();
     $themeService = $this->getMockBuilder('\\Box\\Mod\\Theme\\Service')->getMock();
     $themeService->expects($this->atLeastOnce())->method('getCurrentClientAreaThemeCode');
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function () use($themeService) {
         return $themeService;
     });
     $service->setDi($di);
     $result = $service->getPairs();
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:13,代码来源:ServiceTest.php


示例10: testgetLastExecutionTime

 public function testgetLastExecutionTime()
 {
     $systemServiceMock = $this->getMockBuilder('\\Box\\Mod\\System\\Service')->getMock();
     $systemServiceMock->expects($this->atLeastOnce())->method('getParamValue')->will($this->returnValue('2012-12-12 12:12:12'));
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function ($name) use($systemServiceMock) {
         return $systemServiceMock;
     });
     $service = new \Box\Mod\Cron\Service();
     $service->setDi($di);
     $result = $service->getLastExecutionTime();
     $this->assertInternalType('string', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:13,代码来源:ServiceTest.php


示例11: testGet

 public function testGet()
 {
     $clientService = $this->getMockBuilder('\\Box\\Mod\\Client\\Service')->getMock();
     $clientService->expects($this->atLeastOnce())->method('toApiArray')->will($this->returnValue(array()));
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function () use($clientService) {
         return $clientService;
     });
     $this->clientApi->setDi($di);
     $this->clientApi->setIdentity(new \Model_Client());
     $result = $this->clientApi->get();
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:13,代码来源:ClientTest.php


示例12: testtop_songs

 public function testtop_songs()
 {
     $xmlString = "<note>\n<to>Tove</to>\n<from>Jani</from>\n<heading>Reminder</heading>\n<body>Don't forget me this weekend!</body>\n</note>";
     $data = array();
     $toolsMock = $this->getMockBuilder('\\Box_Tools')->getMock();
     $toolsMock->expects($this->atLeastOnce())->method('file_get_contents')->willReturn($xmlString);
     $di = new \Box_Di();
     $di['tools'] = $toolsMock;
     $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->top_songs($data);
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:15,代码来源:GuestTest.php


示例13: testGetSearchQuery

 public function testGetSearchQuery()
 {
     $service = new Box\Mod\Example\Service();
     $di = new \Box_Di();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $service->setDi($di);
     $data = array('client_id' => 1);
     list($sql, $params) = $service->getSearchQuery($data);
     $this->assertInternalType('string', $sql);
     $this->assertInternalType('array', $params);
     $this->assertArrayHasKey(':client_id', $params);
     $this->assertEquals($params[':client_id'], $data['client_id']);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:15,代码来源:ServiceTest.php


示例14: testTlds

 public function testTlds()
 {
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Servicedomain\\Service')->setMethods(array('tldToApiArray'))->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('tldToApiArray')->will($this->returnValue(array()));
     $this->guestApi->setService($serviceMock);
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('find')->will($this->returnValue(array(new \Model_Tld())));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->guestApi->setDi($di);
     $result = $this->guestApi->tlds(array());
     $this->assertInternalType('array', $result);
     $this->assertInternalType('array', $result[0]);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:17,代码来源:Api_GuestTest.php


示例15: testgetAmountInCents

 public function testgetAmountInCents()
 {
     $model = new \Model_Invoice();
     $model->loadBean(new RedBeanPHP\OODBBean());
     $totalAmountWithTax = 12.23;
     $invoiceServiceMock = $this->getMockBuilder('\\Box\\Mod\\Invoice\\Service')->getMock();
     $invoiceServiceMock->expects($this->atLeastOnce())->method('getTotalWithTax')->with($model)->willReturn($totalAmountWithTax);
     $di = new \Box_Di();
     $di['mod_service'] = $di->protect(function ($serviceName) use($invoiceServiceMock) {
         if ($serviceName == 'Invoice') {
             return $invoiceServiceMock;
         }
     });
     $adapter = new Payment_Adapter_Stripe($this->defaultConfig);
     $adapter->setDi($di);
     $result = $adapter->getAmountInCents($model);
     $this->assertEquals($totalAmountWithTax * 100, $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:18,代码来源:Payment_Adapter_StripeTest.php


示例16: testLogEvent

 public function testLogEvent()
 {
     $service = new \Box\Mod\Activity\Service();
     $data = array('message' => 'Logging test message');
     $di = new \Box_Di();
     $db = $this->getMockBuilder('Box_Database')->getMock();
     $model = new \Model_ActivitySystem();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $db->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($model));
     $db->expects($this->atLeastOnce())->method('store')->will($this->returnValue(array()));
     $di['request'] = $this->getMockBuilder('Box_Request')->getMock();
     $di['db'] = $db;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $service->setDi($di);
     $result = $service->logEvent($data);
     $this->assertNull($result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:19,代码来源:ServiceTest.php


示例17: testsetConfig

 public function testsetConfig()
 {
     $di = new \Box_Di();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray');
     $di['validator'] = $validatorMock;
     $config = array('id' => 123, 'key' => 'verysecrectKey', 'ipaddress' => '123.123.123.123');
     $updatedConfig = array('id' => 123, 'key' => 'verysecrectKey', 'ipaddress' => '123.123.123.123', 'usertype' => 'admin', 'secure' => false, 'port' => NULL);
     $solusVmMock = $this->getMockBuilder('\\Box\\Mod\\Servicesolusvm\\SolusVM')->setMethods(array('getUrl', 'getSecureUrl'))->getMock();
     $url = "http://" . $updatedConfig['ipaddress'] . ":5353/api/" . $updatedConfig['usertype'] . "/command.php";
     $solusVmMock->expects($this->atLeastOnce())->method('getUrl')->with($updatedConfig)->willReturn($url);
     $solusVmMock->expects($this->never())->method('getSecureUrl');
     $solusVmMock->setDi($di);
     $solusVmMock->setConfig($config);
     $this->assertEquals($url, $solusVmMock->getApiHost());
     $this->assertEquals($config['id'], $solusVmMock->getApiID());
     $this->assertEquals($config['key'], $solusVmMock->getApiKey());
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:21,代码来源:SolusVMTest.php


示例18: testfree_tlds_ProductTypeIsNotHosting

 public function testfree_tlds_ProductTypeIsNotHosting()
 {
     $di = new \Box_Di();
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->disableOriginalConstructor()->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray')->will($this->returnValue(null));
     $di['validator'] = $validatorMock;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $model = new \Model_Product();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->will($this->returnValue($model));
     $di['db'] = $dbMock;
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Servicehosting\\Service')->getMock();
     $serviceMock->expects($this->never())->method('getFreeTlds');
     $this->api->setService($serviceMock);
     $this->api->setDi($di);
     $this->setExpectedException('\\Box_Exception', 'Product type is invalid');
     $this->api->free_tlds(array('product_id' => 1));
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:21,代码来源:GuestTest.php


示例19: testCheckout

 public function testCheckout()
 {
     $cart = new \Model_Cart();
     $cart->loadBean(new \RedBeanPHP\OODBBean());
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Cart\\Service')->setMethods(array('getSessionCart', 'checkoutCart'))->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('getSessionCart')->will($this->returnValue($cart));
     $checkOutCartResult = array('gateway_id' => 1, 'invoice_hash' => null, 'order_id' => 1, 'orders' => 1);
     $serviceMock->expects($this->atLeastOnce())->method('checkoutCart')->will($this->returnValue($checkOutCartResult));
     $this->clientApi->setService($serviceMock);
     $client = new \Model_Client();
     $client->loadBean(new \RedBeanPHP\OODBBean());
     $this->clientApi->setIdentity($client);
     $data = array('id' => rand(1, 100));
     $di = new \Box_Di();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->clientApi->setDi($di);
     $result = $this->clientApi->checkout($data);
     $this->assertInternalType('array', $result);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:21,代码来源:ClientTest.php


示例20: test_getServiceOrderNotActivated

 public function test_getServiceOrderNotActivated()
 {
     $data['order_id'] = 1;
     $orderServiceMock = $this->getMockBuilder('\\Box\\Mod\\Order\\Service')->getMock();
     $orderServiceMock->expects($this->atLeastOnce())->method('getOrderService')->will($this->returnValue(null));
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('findOne')->with('ClientOrder')->will($this->returnValue(new \Model_ClientOrder()));
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray');
     $di = new \Box_Di();
     $di['validator'] = $validatorMock;
     $di['db'] = $dbMock;
     $di['mod_service'] = $di->protect(function () use($orderServiceMock) {
         return $orderServiceMock;
     });
     $this->api->setDi($di);
     $clientModel = new \Model_Client();
     $clientModel->loadBean(new \RedBeanPHP\OODBBean());
     $this->api->setIdentity($clientModel);
     $this->setExpectedException('\\Box_Exception', 'Order is not activated');
     $this->api->_getService($data);
 }
开发者ID:Ryan-Nolan,项目名称:boxbilling,代码行数:22,代码来源:ClientTest.php



注:本文中的Box_Di类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Braintree_Configuration类代码示例发布时间:2022-05-23
下一篇:
PHP Box类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap