Пример #1
0
 public function testNoteCreate()
 {
     $randId = rand(1, 100);
     $supportPrCategoryModel = new \Model_SupportPrCategory();
     $supportPrCategoryModel->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->disableOriginalConstructor()->getMock();
     $dbMock->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($supportPrCategoryModel));
     $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue($randId));
     $di = new \Box_Di();
     $di['db'] = $dbMock;
     $di['logger'] = $this->getMockBuilder('Box_Log')->getMock();
     $this->service->setDi($di);
     $data = array('name' => 'Name', 'email' => '*****@*****.**', 'can_reopen' => 1, 'close_after' => rand(1, 100), 'signature' => 'Signature');
     $admin = new \Model_Admin();
     $admin->loadBean(new \RedBeanPHP\OODBBean());
     $ticket = new \Model_SupportTicket();
     $ticket->loadBean(new \RedBeanPHP\OODBBean());
     $result = $this->service->noteCreate($ticket, $admin, 'Note');
     $this->assertInternalType('integer', $result);
     $this->assertEquals($result, $randId);
 }
Пример #2
0
 public function testCanned_category_delete()
 {
     $validatorMock = $this->getMockBuilder('\\Box_Validate')->disableOriginalConstructor()->getMock();
     $validatorMock->expects($this->atLeastOnce())->method('checkRequiredParamsForArray')->will($this->returnValue(null));
     $supportCategory = new \Model_SupportPrCategory();
     $supportCategory->loadBean(new \RedBeanPHP\OODBBean());
     $dbMock = $this->getMockBuilder('\\Box_Database')->disableOriginalConstructor()->getMock();
     $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->will($this->returnValue($supportCategory));
     $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Support\\Service')->setMethods(array('cannedCategoryRm'))->getMock();
     $serviceMock->expects($this->atLeastOnce())->method('cannedCategoryRm')->will($this->returnValue(array()));
     $di = new \Box_Di();
     $di['validator'] = $validatorMock;
     $di['db'] = $dbMock;
     $this->adminApi->setDi($di);
     $this->adminApi->setService($serviceMock);
     $this->adminApi->setIdentity(new \Model_Admin());
     $data = array('id' => rand(1, 100));
     $result = $this->adminApi->canned_category_delete($data);
     $this->assertInternalType('array', $result);
 }