Пример #1
0
 public function testOperatingOnData()
 {
     $val1 = array('key' => 'foo', 'val' => 1);
     $val2 = array('key' => 'bar', 'val' => array(1, 2, 3));
     $this->object->setVal($val1['key'], $val1['val']);
     $this->object->setVal($val2['key'], $val2['val']);
     $this->assertEquals(2, count($this->object->getData()));
     $this->assertEquals($val1['val'], $this->object->getVal($val1['key']));
     $this->assertEquals($val2['val'], $this->object->getVal($val2['key']));
     $this->assertEquals('HelloWorld', $this->object->getVal('nonExistentVal', 'HelloWorld'));
     $this->object->setData(array());
     $this->assertEmpty($this->object->getData());
 }
 /**
  * After the forms is sent to the proper Email Controller, inspect the result.
  * If it's "ok", add a confirmation banner notification to indicate success. Otherwise
  * add an error banner notification and output the error from the Email Controller.
  * @param \WikiaResponse $result
  */
 private function addBannerNotification($result)
 {
     $responseData = $result->getData();
     if ($responseData['result'] == 'ok') {
         \BannerNotificationsController::addConfirmation("Successfully sent email!", \BannerNotificationsController::CONFIRMATION_CONFIRM);
     } else {
         \BannerNotificationsController::addConfirmation("Errors: " . $responseData['msg'], \BannerNotificationsController::CONFIRMATION_ERROR);
     }
 }
Пример #3
0
 protected function renderInvalid()
 {
     $output = $this->response->getData();
     $output += array('exception' => array('message' => "Invalid Format, defaulting to JSON", 'code' => WikiaResponse::RESPONSE_CODE_ERROR));
     return json_encode($output);
 }
Пример #4
0
 protected function assertSuccessfulEmail(WikiaResponse $resp = null)
 {
     if (empty($resp)) {
         throw new RequestException("Got empty response from the {$this->type} email controller");
     }
     $data = $resp->getData();
     if (empty($data['result']) || $data['result'] != 'ok') {
         throw new RequestException("Failed to send email:\n" . print_r($data, true));
     }
 }