Beispiel #1
0
 public function testTldUpdate()
 {
     $data = array();
     $data['tld'] = '.com';
     $data['tld_registrar_id'] = rand(1, 100);
     $data['price_registration'] = rand(1, 10);
     $data['price_renew'] = rand(1, 10);
     $data['price_transfer'] = rand(1, 10);
     $data['min_years'] = rand(1, 5);
     $data['allow_register'] = true;
     $data['allow_transfer'] = true;
     $data['active'] = true;
     $data['updated_at'] = date('Y-m-d H:i:s');
     $data['created_at'] = date('Y-m-d H:i:s');
     $randId = rand(1, 100);
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue($randId));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['logger'] = $this->getMockBuilder('Box_Log')->getMock();
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $this->service->setDi($di);
     $model = new \Model_Tld();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $model->tld = '.com';
     $result = $this->service->tldUpdate($model, $data);
     $this->assertTrue($result);
 }
Beispiel #2
0
 public function testCreateCurrency()
 {
     $service = new \Box\Mod\Currency\Service();
     $code = 'EUR';
     $format = '€{{price}}';
     $systemService = $this->getMockBuilder('\\Box\\Mod\\System\\Service')->setMethods(array('checkLimits'))->getMock();
     $systemService->expects($this->atLeastOnce())->method('checkLimits')->will($this->returnValue(null));
     $currencyModel = new \Model_Tld();
     $currencyModel->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue(rand(1, 100)));
     $dbMock->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($currencyModel));
     $di = new \Box_Di();
     $di['logger'] = new \Box_Log();
     $di['db'] = $dbMock;
     $di['mod_service'] = $di->protect(function () use($systemService) {
         return $systemService;
     });
     $service->setDi($di);
     $result = $service->createCurrency($code, $format, 'Euros', 0.6);
     $this->assertInternalType('string', $result);
     $this->assertEquals(strlen($result), 3);
     $this->assertEquals($result, $code);
 }
Beispiel #3
0
 public function testgetFreeTlds_FreeTldsAreNotSet()
 {
     $config = array();
     $di = new \Box_Di();
     $toolsMock = $this->getMockBuilder('\\Box_Tools')->getMock();
     $toolsMock->expects($this->atLeastOnce())->method('decodeJ')->willReturn($config);
     $di['tools'] = $toolsMock;
     $di['array_get'] = $di->protect(function (array $array, $key, $default = null) use($di) {
         return isset($array[$key]) ? $array[$key] : $default;
     });
     $tldArray = array('tld' => '.com');
     $serviceDomainServiceMock = $this->getMockBuilder('\\Box\\Mod\\Servicedomain\\Service')->getMock();
     $serviceDomainServiceMock->expects($this->atLeastOnce())->method('tldToApiArray')->willReturn($tldArray);
     $di['mod_service'] = $di->protect(function () use($serviceDomainServiceMock) {
         return $serviceDomainServiceMock;
     });
     $tldModel = new \Model_Tld();
     $tldModel->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('find')->willReturn(array($tldModel));
     $di['db'] = $dbMock;
     $this->service->setDi($di);
     $model = new \Model_Product();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $result = $this->service->getFreeTlds($model);
     $this->assertInternalType('array', $result);
 }