Permalink
Browse files

Completed tests for JWeb::redirect.

  • Loading branch information...
1 parent 396c1e8 commit 7708c99721a2078725284daf5dcf92bbac562330 @eddieajau eddieajau committed Sep 20, 2011
Showing with 49 additions and 0 deletions.
  1. +49 −0 tests/suite/joomla/application/JWebTest.php
@@ -80,6 +80,22 @@ public function getFetchConfigurationData()
}
/**
+ * Data for fetchConfigurationData method.
+ *
+ * @return array
+ *
+ * @since 11.3
+ */
+ public function getRedirectData()
+ {
+ return array(
+ // url, base, request, (expected result)
+ array('/foo', 'http://j.org/', 'http://j.org/index.php?v=11.3', 'http://j.org/foo'),
+ array('foo', 'http://j.org/', 'http://j.org/index.php?v=11.3', 'http://j.org/foo'),
+ );
+ }
+
+ /**
* Setup for testing.
*
* @return void
@@ -1250,6 +1266,39 @@ public function testRedirectWithMoved()
}
/**
+ * Tests the JWeb::redirect method with assorted URL's.
+ *
+ * @return void
+ *
+ * @dataProvider getRedirectData
+ * @since 11.3
+ */
+ public function testRedirectWithUrl($url, $base, $request, $expected)
+ {
+ // Inject the client information.
+ $this->inspector->setClassProperty(
+ 'client',
+ (object) array(
+ 'engine' => JWebClient::GECKO,
+ )
+ );
+
+ // Inject the internal configuration.
+ $config = new JRegistry;
+ $config->set('uri.base.full', $base);
+ $config->set('uri.request', $request);
+
+ $this->inspector->setClassProperty('config', $config);
+
+ $this->inspector->redirect($url, false);
+
+ $this->assertThat(
+ $this->inspector->headers[1][0],
+ $this->equalTo('Location: '.$expected)
+ );
+ }
+
+ /**
* Tests the JWeb::redirect method with webkit bug.
*
* @return void

0 comments on commit 7708c99

Please sign in to comment.