Ejemplo n.º 1
0
 /**
  * @expectedException \Box_Exception
  */
 public function testRegistrar_updateIdNotSetException()
 {
     $registrar = new \Model_TldRegistrar();
     $registrar->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->never())->method('load')->will($this->returnValue($registrar));
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Servicedomain\\Service')->getMock();
     $serviceMock->expects($this->never())->method('registrarUpdate')->will($this->returnValue(true));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->disableOriginalConstructor()->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray')->willThrowException(new \Box_Exception('Registrar ID is missing'));
     $di['validator'] = $validatorMock;
     $this->adminApi->setDi($di);
     $this->adminApi->setService($serviceMock);
     $data = array();
     $result = $this->adminApi->registrar_update($data);
     $this->assertTrue($result);
 }
Ejemplo n.º 2
0
 public function testRegistrarUpdate()
 {
     $dbMock = $this->getMockBuilder('\\Box_Database')->getMock();
     $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue(rand(1, 100)));
     $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);
     $data = array('title' => 'ResellerClub', 'test_mode' => 1, 'config' => array('param1' => 'value1'));
     $model = new \Model_TldRegistrar();
     $model->loadBean(new \RedBeanPHP\OODBBean());
     $model->registrar = 'Custom';
     $result = $this->service->registrarUpdate($model, $data);
     $this->assertTrue($result);
 }