コード例 #1
0
 /**
  * Update action
  *
  * @return JsonModel
  */
 public function updateAction()
 {
     $postPayload = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $errorMessage = '';
     if (isset($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES]) && is_array($postPayload[UpdaterTaskCreator::KEY_POST_PACKAGES]) && isset($postPayload[UpdaterTaskCreator::KEY_POST_JOB_TYPE])) {
         $errorMessage .= $this->payloadValidator->validatePayload($postPayload);
         if (empty($errorMessage)) {
             $errorMessage = $this->updaterTaskCreator->createUpdaterTasks($postPayload);
         }
     } else {
         $errorMessage .= 'Invalid request';
     }
     $success = empty($errorMessage);
     return new JsonModel(['success' => $success, 'message' => $errorMessage]);
 }
コード例 #2
0
 /**
  * @param string $type
  * @param int $has
  * @param bool $moduleExists
  * @param string $errorMessage
  * @dataProvider validatePayLoadNegativeCasesDataProvider
  */
 public function testValidatePayLoadNegativeCases($type, $has, $moduleExists, $errorMessage)
 {
     $this->fullModuleList->expects($this->exactly($has))->method('has')->willReturn($moduleExists);
     $this->assertStringStartsWith($errorMessage, $this->model->validatePayload($type));
 }