mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing some failing test cases
This commit is contained in:
parent
979f7a28b5
commit
769a5c24e6
2 changed files with 18 additions and 9 deletions
|
@ -48,51 +48,59 @@ class RedirectRouteTestCase extends CakeTestCase {
|
|||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/home');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/posts', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/posts', true));
|
||||
|
||||
$route = new RedirectRoute('/home', array('controller' => 'posts', 'action' => 'index'));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/home');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/posts', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/posts', true));
|
||||
$this->assertEquals($route->response->statusCode(), 301);
|
||||
|
||||
$route = new RedirectRoute('/google', 'http://google.com');
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/google');
|
||||
$this->assertEquals($route->response->header(), array('Location' => 'http://google.com'));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], 'http://google.com');
|
||||
|
||||
$route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('status' => 302));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/posts/view', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/posts/view', true));
|
||||
$this->assertEquals($route->response->statusCode(), 302);
|
||||
|
||||
$route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/posts/view/2', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/posts/view/2', true));
|
||||
|
||||
$route = new RedirectRoute('/posts/*', '/test', array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/posts/2');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/test', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/test', true));
|
||||
|
||||
$route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'), array('persist' => true));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/tags/add/passme/named:param', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/tags/add/passme/named:param', true));
|
||||
|
||||
$route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'));
|
||||
$route->stop = false;
|
||||
$route->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
$result = $route->parse('/my_controllers/do_something/passme/named:param');
|
||||
$this->assertEquals($route->response->header(), array('Location' => Router::url('/tags/add', true)));
|
||||
$header = $route->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/tags/add', true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2498,7 +2498,8 @@ class RouterTest extends CakeTestCase {
|
|||
$this->assertEquals(Router::$routes[0]->options['status'], 302);
|
||||
|
||||
Router::parse('/blog');
|
||||
$this->assertEquals(Router::$routes[0]->response->header(), array('Location' => Router::url('/posts', true)));
|
||||
$header = Router::$routes[0]->response->header();
|
||||
$this->assertEquals($header['Location'], Router::url('/posts', true));
|
||||
$this->assertEquals(Router::$routes[0]->response->statusCode(), 302);
|
||||
|
||||
Router::$routes[0]->response = $this->getMock('CakeResponse', array('_sendHeader'));
|
||||
|
|
Loading…
Add table
Reference in a new issue