コード例 #1
0
	/**
	 * Tests the JApplicationWeb::redirect method with assorted URL's.
	 *
	 * @param   string  $url       @todo
	 * @param   string  $base      @todo
	 * @param   string  $request   @todo
	 * @param   string  $expected  @todo
	 *
	 * @return  void
	 *
	 * @dataProvider  getRedirectData
	 * @since   11.3
	 */
	public function testRedirectWithUrl($url, $base, $request, $expected)
	{
		// 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);
		$config->set('uri.request', $request);

		TestReflection::setValue($this->class, 'config', $config);

		$this->class->redirect($url, false);

		$this->assertThat(
			$this->class->headers[1][0],
			$this->equalTo('Location: ' . $expected)
		);
	}
コード例 #2
0
 /**
  * Tests the JApplicationWeb::redirect method with webkit bug.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testRedirectWithWebkitBug()
 {
     $url = 'http://j.org/index.php';
     // Inject the client information.
     TestReflection::setValue($this->class, 'client', (object) array('engine' => JApplicationWebClient::WEBKIT));
     // Capture the output for this test.
     ob_start();
     $this->class->redirect($url);
     $buffer = ob_get_contents();
     ob_end_clean();
     $this->assertThat(trim($buffer), $this->equalTo('<html><head>' . '<meta http-equiv="refresh" content="0; url=' . $url . '" />' . '<meta http-equiv="content-type" content="text/html; charset=utf-8" />' . '</head><body></body></html>'));
 }