public function testPublicTicketReplyForGuest() { $message = new \Model_SupportTicketMessage(); $message->loadBean(new \RedBeanPHP\OODBBean()); $randId = rand(1, 100); $dbMock = $this->getMockBuilder('\\Box_Database')->disableOriginalConstructor()->getMock(); $dbMock->expects($this->atLeastOnce())->method('dispense')->will($this->returnValue($message)); $dbMock->expects($this->atLeastOnce())->method('store')->will($this->returnValue($randId)); $eventMock = $this->getMockBuilder('\\Box_EventManager')->getMock(); $eventMock->expects($this->atLeastOnce())->method('fire'); $di = new \Box_Di(); $di['db'] = $dbMock; $di['logger'] = $this->getMockBuilder('Box_Log')->getMock(); $di['request'] = $this->getMockBuilder('Box_Request')->getMock(); $di['events_manager'] = $eventMock; $this->service->setDi($di); $ticket = new \Model_SupportPTicket(); $ticket->loadBean(new \RedBeanPHP\OODBBean()); $ticket->hash = sha1(uniqid()); $admin = new \Model_Admin(); $admin->loadBean(new \RedBeanPHP\OODBBean()); $result = $this->service->publicTicketReplyForGuest($ticket, 'Message'); $this->assertInternalType('string', $result); $this->assertEquals(strlen($result), 40); }
public function testPublic_ticket_get_list() { $resultSet = array('list' => array(0 => array('id' => 1))); $paginatorMock = $this->getMockBuilder('\\Box_Pagination')->disableOriginalConstructor()->getMock(); $paginatorMock->expects($this->atLeastOnce())->method('getAdvancedResultSet')->will($this->returnValue($resultSet)); $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Support\\Service')->setMethods(array('publicGetSearchQuery', 'publicToApiArray'))->getMock(); $serviceMock->expects($this->atLeastOnce())->method('publicGetSearchQuery')->will($this->returnValue(array('query', array()))); $serviceMock->expects($this->atLeastOnce())->method('publicToApiArray')->will($this->returnValue(array('query', array()))); $model = new \Model_SupportPTicket(); $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->adminApi->setDi($di); $this->adminApi->setService($serviceMock); $data = array(); $result = $this->adminApi->public_ticket_get_list($data); $this->assertInternalType('array', $result); }