コード例 #1
0
 /**
  * Tests the JApplicationCms::redirect method.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testRedirectLegacy()
 {
     $base = 'http://mydomain.com/';
     $url = 'index.php';
     // Inject the client information.
     TestReflection::setValue($this->class, 'client', (object) array('engine' => JApplicationWebClient::GECKO));
     // Inject the internal configuration.
     $config = new JRegistry();
     $config->set('uri.base.full', $base);
     TestReflection::setValue($this->class, 'config', $config);
     $this->class->redirect($url, 'Test Message', 'message', false);
     $messageQueue = $this->class->getMessageQueue();
     $this->assertThat($messageQueue, $this->equalTo(array(array('message' => 'Test Message', 'type' => 'message'))), 'Tests to ensure legacy redirect handling works');
     $this->assertThat($this->class->headers, $this->equalTo(array(array('HTTP/1.1 303 See other', true, null), array('Location: ' . $base . $url, true, null), array('Content-Type: text/html; charset=utf-8', true, null))));
 }
コード例 #2
0
 /**
  * Tests the JApplicationCms::redirect method.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testRedirectLegacyWithEmptyMessageAndEmptyStatus()
 {
     $base = 'http://mydomain.com/';
     $url = 'index.php';
     // Inject the client information.
     TestReflection::setValue($this->class, 'client', (object) array('engine' => JApplicationWebClient::GECKO));
     // Inject the internal configuration.
     $config = new Registry();
     $config->set('uri.base.full', $base);
     TestReflection::setValue($this->class, 'config', $config);
     $this->class->redirect($url, '', 'message');
     // The message isn't enqueued as it's an empty string
     $this->assertEmpty($this->class->getMessageQueue());
     // The redirect gives a 303 error code
     $this->assertEquals(array(array('HTTP/1.1 303 See other', true, null), array('Location: ' . $base . $url, true, null), array('Content-Type: text/html; charset=utf-8', true, null)), $this->class->headers);
 }