public function testPushTaskSimplestAdd() { $req = self::buildBulkAddRequest(); $resp = new TaskQueueBulkAddResponse(); $task_result = $resp->addTaskResult(); $task_result->setResult(ErrorCode::OK); $task_result->setChosenTaskName('fred'); $this->apiProxyMock->expectCall('taskqueue', 'BulkAdd', $req, $resp); $task_name = (new PushTask('/someUrl'))->add(); $this->assertEquals('fred', $task_name); $this->apiProxyMock->verify(); }
public function testPushTaskAddWithTwoHeaders() { $req = self::buildBulkAddRequest(); $add_req = $req->getAddRequest(0); $header = $add_req->addHeader(); $header->setKey('custom-header'); $header->setValue('54321'); $header = $add_req->addHeader(); $header->setKey('another-custom-header'); $header->setValue('abc'); $resp = new TaskQueueBulkAddResponse(); $task_result = $resp->addTaskResult(); $task_result->setResult(ErrorCode::OK); $task_result->setChosenTaskName('fred'); $this->apiProxyMock->expectCall('taskqueue', 'BulkAdd', $req, $resp); $task_name = (new PushTask('/someUrl', [], ['header' => "custom-header: 54321\r\n" . 'another-custom-header: abc']))->add(); $this->assertEquals('fred', $task_name); $this->apiProxyMock->verify(); }
public function testPushQueueTooManyTasksError() { $req = self::buildBulkAddRequestWithTwoTasks(); $resp = new TaskQueueBulkAddResponse(); $task_result = $resp->addTaskResult(); $task_result->setResult(ErrorCode::OK); $task_result->setChosenTaskName('fred'); $task_result = $resp->addTaskResult(); $task_result->setResult(ErrorCode::TOO_MANY_TASKS); $task_result->setChosenTaskName('bob'); $this->setExpectedException('\\google\\appengine\\api\\taskqueue\\TaskQueueException', 'Too many tasks in request.'); $this->apiProxyMock->expectCall('taskqueue', 'BulkAdd', $req, $resp); $task1 = new PushTask('/someUrl'); $task2 = new PushTask('/someOtherUrl'); $queue = new PushQueue(); $queue->addTasks([$task1, $task2]); $this->apiProxyMock->verify(); }