mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Changed tests to support PHP 5.2 :(
This commit is contained in:
parent
5d016a7dbf
commit
5af3da7fe6
1 changed files with 21 additions and 24 deletions
|
@ -1066,13 +1066,16 @@ class CakeResponseTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @dataProvider corsData
|
* @dataProvider corsData
|
||||||
* @param CakeRequest $request
|
* @param CakeRequest $request
|
||||||
|
* @param string $origin
|
||||||
* @param string|array $domains
|
* @param string|array $domains
|
||||||
* @param string|array $methods
|
* @param string|array $methods
|
||||||
* @param string|boolean $expectedOrigin
|
* @param string|boolean $expectedOrigin
|
||||||
* @param string|boolean $expectedMethods
|
* @param string|boolean $expectedMethods
|
||||||
* @return void
|
* @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'));
|
$response = $this->getMock('CakeResponse', array('header'));
|
||||||
if ($expectedOrigin === false) {
|
if ($expectedOrigin === false) {
|
||||||
$response->expects($this->never())
|
$response->expects($this->never())
|
||||||
|
@ -1091,6 +1094,7 @@ class CakeResponseTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
$response->cors($request, $domains, $methods);
|
$response->cors($request, $domains, $methods);
|
||||||
|
unset($_SERVER['HTTP_ORIGIN']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1099,38 +1103,31 @@ class CakeResponseTest extends CakeTestCase {
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function corsData() {
|
public function corsData() {
|
||||||
$fooRequest = $this->getMock('CakeRequest', array('header'));
|
$fooRequest = new CakeRequest();
|
||||||
$fooRequest::staticExpects($this->any())
|
|
||||||
->method('header')
|
|
||||||
->with('Origin')
|
|
||||||
->will($this->returnValue('http://www.foo.com'));
|
|
||||||
|
|
||||||
$secureRequest = $this->getMock('CakeRequest', array('header', 'is'));
|
$secureRequest = $this->getMock('CakeRequest', array('is'));
|
||||||
$secureRequest::staticExpects($this->any())
|
|
||||||
->method('header')
|
|
||||||
->with('Origin')
|
|
||||||
->will($this->returnValue('https://www.bar.com'));
|
|
||||||
$secureRequest->expects($this->any())
|
$secureRequest->expects($this->any())
|
||||||
->method('is')
|
->method('is')
|
||||||
->with('ssl')
|
->with('ssl')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($fooRequest, '*', '', '*', false),
|
array($fooRequest, null, '*', '', false, false),
|
||||||
array($fooRequest, 'www.foo.com', '', 'http://www.foo.com', false),
|
array($fooRequest, 'http://www.foo.com', '*', '', '*', false),
|
||||||
array($fooRequest, '*.foo.com', '', 'http://www.foo.com', false),
|
array($fooRequest, 'http://www.foo.com', 'www.foo.com', '', 'http://www.foo.com', false),
|
||||||
array($fooRequest, 'http://*.foo.com', '', 'http://www.foo.com', false),
|
array($fooRequest, 'http://www.foo.com', '*.foo.com', '', 'http://www.foo.com', false),
|
||||||
array($fooRequest, 'https://www.foo.com', '', false, false),
|
array($fooRequest, 'http://www.foo.com', 'http://*.foo.com', '', 'http://www.foo.com', false),
|
||||||
array($fooRequest, 'https://*.foo.com', '', false, false),
|
array($fooRequest, 'http://www.foo.com', 'https://www.foo.com', '', false, false),
|
||||||
array($fooRequest, array('*.bar.com', '*.foo.com'), '', 'http://www.foo.com', 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, 'www.bar.com', '', 'https://www.bar.com', false),
|
array($secureRequest, 'https://www.bar.com', 'www.bar.com', '', 'https://www.bar.com', false),
|
||||||
array($secureRequest, 'http://www.bar.com', '', false, false),
|
array($secureRequest, 'https://www.bar.com', 'http://www.bar.com', '', false, false),
|
||||||
array($secureRequest, '*.bar.com', '', 'https://www.bar.com', false),
|
array($secureRequest, 'https://www.bar.com', '*.bar.com', '', 'https://www.bar.com', false),
|
||||||
|
|
||||||
array($fooRequest, '*', 'GET', '*', 'GET'),
|
array($fooRequest, 'http://www.foo.com', '*', 'GET', '*', 'GET'),
|
||||||
array($fooRequest, '*.foo.com', 'GET', 'http://www.foo.com', 'GET'),
|
array($fooRequest, 'http://www.foo.com', '*.foo.com', 'GET', 'http://www.foo.com', 'GET'),
|
||||||
array($fooRequest, '*.foo.com', array('GET', 'POST'), 'http://www.foo.com', 'GET, POST'),
|
array($fooRequest, 'http://www.foo.com', '*.foo.com', array('GET', 'POST'), 'http://www.foo.com', 'GET, POST'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue