Permalink
Browse files

Changed tests to support PHP 5.2 :(

  • Loading branch information...
1 parent 5d016a7 commit 5af3da7fe66ca138a6726b7b6f3f36cee60e8548 @jrbasso jrbasso committed Jan 21, 2014
Showing with 23 additions and 26 deletions.
  1. +23 −26 lib/Cake/Test/Case/Network/CakeResponseTest.php
View
49 lib/Cake/Test/Case/Network/CakeResponseTest.php
@@ -1066,13 +1066,16 @@ public function testCookieSettings() {
*
* @dataProvider corsData
* @param CakeRequest $request
+ * @param string $origin
* @param string|array $domains
* @param string|array $methods
* @param string|boolean $expectedOrigin
* @param string|boolean $expectedMethods
* @return void
*/
- public function testCors($request, $domains, $methods, $expectedOrigin, $expectedMethods) {
+ public function testCors($request, $origin, $domains, $methods, $expectedOrigin, $expectedMethods) {
+ $_SERVER['HTTP_ORIGIN'] = $origin;
+
$response = $this->getMock('CakeResponse', array('header'));
if ($expectedOrigin === false) {
$response->expects($this->never())
@@ -1091,6 +1094,7 @@ public function testCors($request, $domains, $methods, $expectedOrigin, $expecte
}
$response->cors($request, $domains, $methods);
+ unset($_SERVER['HTTP_ORIGIN']);
}
/**
@@ -1099,38 +1103,31 @@ public function testCors($request, $domains, $methods, $expectedOrigin, $expecte
* @return array
*/
public function corsData() {
- $fooRequest = $this->getMock('CakeRequest', array('header'));
- $fooRequest::staticExpects($this->any())
- ->method('header')
- ->with('Origin')
- ->will($this->returnValue('http://www.foo.com'));
+ $fooRequest = new CakeRequest();
- $secureRequest = $this->getMock('CakeRequest', array('header', 'is'));
- $secureRequest::staticExpects($this->any())
- ->method('header')
- ->with('Origin')
- ->will($this->returnValue('https://www.bar.com'));
+ $secureRequest = $this->getMock('CakeRequest', array('is'));
$secureRequest->expects($this->any())
->method('is')
->with('ssl')
->will($this->returnValue(true));
return array(
- array($fooRequest, '*', '', '*', false),
- array($fooRequest, 'www.foo.com', '', 'http://www.foo.com', false),
- array($fooRequest, '*.foo.com', '', 'http://www.foo.com', false),
- array($fooRequest, 'http://*.foo.com', '', 'http://www.foo.com', false),
- array($fooRequest, 'https://www.foo.com', '', false, false),
- array($fooRequest, 'https://*.foo.com', '', false, false),
- array($fooRequest, array('*.bar.com', '*.foo.com'), '', 'http://www.foo.com', false),
-
- array($secureRequest, 'www.bar.com', '', 'https://www.bar.com', false),
- array($secureRequest, 'http://www.bar.com', '', false, false),
- array($secureRequest, '*.bar.com', '', 'https://www.bar.com', false),
-
- array($fooRequest, '*', 'GET', '*', 'GET'),
- array($fooRequest, '*.foo.com', 'GET', 'http://www.foo.com', 'GET'),
- array($fooRequest, '*.foo.com', array('GET', 'POST'), 'http://www.foo.com', 'GET, POST'),
+ array($fooRequest, null, '*', '', false, false),
+ array($fooRequest, 'http://www.foo.com', '*', '', '*', false),
+ array($fooRequest, 'http://www.foo.com', 'www.foo.com', '', 'http://www.foo.com', false),
+ array($fooRequest, 'http://www.foo.com', '*.foo.com', '', 'http://www.foo.com', false),
+ array($fooRequest, 'http://www.foo.com', 'http://*.foo.com', '', 'http://www.foo.com', false),
+ array($fooRequest, 'http://www.foo.com', 'https://www.foo.com', '', false, false),
+ array($fooRequest, 'http://www.foo.com', 'https://*.foo.com', '', false, false),
+ array($fooRequest, 'http://www.foo.com', array('*.bar.com', '*.foo.com'), '', 'http://www.foo.com', false),
+
+ array($secureRequest, 'https://www.bar.com', 'www.bar.com', '', 'https://www.bar.com', false),
+ array($secureRequest, 'https://www.bar.com', 'http://www.bar.com', '', false, false),
+ array($secureRequest, 'https://www.bar.com', '*.bar.com', '', 'https://www.bar.com', false),
+
+ array($fooRequest, 'http://www.foo.com', '*', 'GET', '*', 'GET'),
+ array($fooRequest, 'http://www.foo.com', '*.foo.com', 'GET', 'http://www.foo.com', 'GET'),
+ array($fooRequest, 'http://www.foo.com', '*.foo.com', array('GET', 'POST'), 'http://www.foo.com', 'GET, POST'),
);
}

0 comments on commit 5af3da7

Please sign in to comment.