mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge branch '2.1' of github.com:cakephp/cakephp into 2.1
This commit is contained in:
commit
542e5c91de
17 changed files with 203 additions and 22 deletions
35
app/Controller/AppController.php
Normal file
35
app/Controller/AppController.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Application level Controller
|
||||
*
|
||||
* This file is application-wide controller file. You can put all
|
||||
* application-wide controller-related methods here.
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('Controller', 'Controller');
|
||||
|
||||
/**
|
||||
* Application Controller
|
||||
*
|
||||
* Add your application-wide methods in the class below, your controllers
|
||||
* will inherit them.
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
}
|
82
app/Controller/PagesController.php
Normal file
82
app/Controller/PagesController.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
/**
|
||||
* Static content controller.
|
||||
*
|
||||
* This file will render views from views/pages/
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Controller
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('AppController', 'Controller');
|
||||
|
||||
/**
|
||||
* Static content controller
|
||||
*
|
||||
* Override this controller by placing a copy in controllers directory of an application
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
|
||||
*/
|
||||
class PagesController extends AppController {
|
||||
|
||||
/**
|
||||
* Controller name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name = 'Pages';
|
||||
|
||||
/**
|
||||
* Default helper
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $helpers = array('Html', 'Session');
|
||||
|
||||
/**
|
||||
* This controller does not use a model
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
/**
|
||||
* Displays a view
|
||||
*
|
||||
* @param mixed What page to display
|
||||
* @return void
|
||||
*/
|
||||
public function display() {
|
||||
$path = func_get_args();
|
||||
|
||||
$count = count($path);
|
||||
if (!$count) {
|
||||
$this->redirect('/');
|
||||
}
|
||||
$page = $subpage = $title_for_layout = null;
|
||||
|
||||
if (!empty($path[0])) {
|
||||
$page = $path[0];
|
||||
}
|
||||
if (!empty($path[1])) {
|
||||
$subpage = $path[1];
|
||||
}
|
||||
if (!empty($path[$count - 1])) {
|
||||
$title_for_layout = Inflector::humanize($path[$count - 1]);
|
||||
}
|
||||
$this->set(compact('page', 'subpage', 'title_for_layout'));
|
||||
$this->render(implode('/', $path));
|
||||
}
|
||||
}
|
34
app/Model/AppModel.php
Normal file
34
app/Model/AppModel.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* Application model for Cake.
|
||||
*
|
||||
* This file is application-wide model file. You can put all
|
||||
* application-wide model-related methods here.
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package app.Model
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
App::uses('Model', 'Model');
|
||||
|
||||
/**
|
||||
* Application model for Cake.
|
||||
*
|
||||
* Add your application-wide methods in the class below, your models
|
||||
* will inherit them.
|
||||
*
|
||||
* @package app.Model
|
||||
*/
|
||||
class AppModel extends Model {
|
||||
}
|
|
@ -15,20 +15,19 @@
|
|||
*
|
||||
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.View.Helper
|
||||
* @package app.View.Helper
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::uses('Helper', 'View');
|
||||
|
||||
/**
|
||||
* This is a placeholder class.
|
||||
* Create the same file in app/View/Helper/AppHelper.php
|
||||
* Application helper
|
||||
*
|
||||
* Add your application-wide methods in the class below, your helpers
|
||||
* will inherit them.
|
||||
*
|
||||
* @package Cake.View.Helper
|
||||
* @package app.View.Helper
|
||||
*/
|
||||
class AppHelper extends Helper {
|
||||
}
|
|
@ -29,6 +29,7 @@ App::uses('Controller', 'Controller');
|
|||
* will inherit them.
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers.html#the-app-controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* Override this controller by placing a copy in controllers directory of an application
|
||||
*
|
||||
* @package app.Controller
|
||||
* @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
|
||||
*/
|
||||
class PagesController extends AppController {
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
App::uses('Helper', 'View');
|
||||
|
||||
/**
|
||||
* This is a placeholder class.
|
||||
* Create the same file in app/View/Helper/AppHelper.php
|
||||
* Application helper
|
||||
*
|
||||
* Add your application-wide methods in the class below, your helpers
|
||||
* will inherit them.
|
||||
|
|
|
@ -63,6 +63,7 @@ class HttpSocket extends CakeSocket {
|
|||
'User-Agent' => 'CakePHP'
|
||||
),
|
||||
'raw' => null,
|
||||
'redirect' => false,
|
||||
'cookies' => array()
|
||||
);
|
||||
|
||||
|
@ -91,13 +92,13 @@ class HttpSocket extends CakeSocket {
|
|||
'protocol' => 'tcp',
|
||||
'port' => 80,
|
||||
'timeout' => 30,
|
||||
'redirect' => false,
|
||||
'request' => array(
|
||||
'uri' => array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'localhost',
|
||||
'port' => 80
|
||||
),
|
||||
'redirect' => false,
|
||||
'cookies' => array()
|
||||
)
|
||||
);
|
||||
|
@ -378,8 +379,10 @@ class HttpSocket extends CakeSocket {
|
|||
}
|
||||
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
|
||||
}
|
||||
if($this->config['redirect'] && $this->response->isRedirect()) {
|
||||
|
||||
if($this->request['redirect'] && $this->response->isRedirect()) {
|
||||
$request['uri'] = $this->response->getHeader('Location');
|
||||
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
|
||||
$this->response = $this->request($request);
|
||||
}
|
||||
|
||||
|
|
|
@ -316,11 +316,6 @@ class AppTest extends CakeTestCase {
|
|||
$result = App::objects('Model/Behavior', null, false);
|
||||
$this->assertTrue(in_array('TreeBehavior', $result));
|
||||
|
||||
$result = App::objects('controller', null, false);
|
||||
$this->assertTrue(in_array('PagesController', $result));
|
||||
$result = App::objects('Controller', null, false);
|
||||
$this->assertTrue(in_array('PagesController', $result));
|
||||
|
||||
$result = App::objects('component', null, false);
|
||||
$this->assertTrue(in_array('AuthComponent', $result));
|
||||
$result = App::objects('Controller/Component', null, false);
|
||||
|
|
|
@ -252,13 +252,13 @@ class HttpSocketTest extends CakeTestCase {
|
|||
'protocol' => 'tcp',
|
||||
'port' => 23,
|
||||
'timeout' => 30,
|
||||
'redirect' => false,
|
||||
'request' => array(
|
||||
'uri' => array(
|
||||
'scheme' => 'https',
|
||||
'host' => 'www.cakephp.org',
|
||||
'port' => 23
|
||||
),
|
||||
'redirect' => false,
|
||||
'cookies' => array()
|
||||
)
|
||||
);
|
||||
|
@ -277,13 +277,13 @@ class HttpSocketTest extends CakeTestCase {
|
|||
'protocol' => 'tcp',
|
||||
'port' => 80,
|
||||
'timeout' => 30,
|
||||
'redirect' => false,
|
||||
'request' => array(
|
||||
'uri' => array(
|
||||
'scheme' => 'http',
|
||||
'host' => 'www.foo.com',
|
||||
'port' => 80
|
||||
),
|
||||
'redirect' => false,
|
||||
'cookies' => array()
|
||||
)
|
||||
);
|
||||
|
@ -318,13 +318,13 @@ class HttpSocketTest extends CakeTestCase {
|
|||
'protocol' => 'tcp',
|
||||
'port' => 80,
|
||||
'timeout' => 30,
|
||||
'redirect' => false,
|
||||
'request' => array(
|
||||
'uri' => array (
|
||||
'scheme' => 'http',
|
||||
'host' => 'www.cakephp.org',
|
||||
'port' => 80
|
||||
),
|
||||
'redirect' => false,
|
||||
'cookies' => array()
|
||||
)
|
||||
),
|
||||
|
@ -345,6 +345,7 @@ class HttpSocketTest extends CakeTestCase {
|
|||
'line' => "GET /?foo=bar HTTP/1.1\r\n",
|
||||
'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n",
|
||||
'raw' => "",
|
||||
'redirect' => false,
|
||||
'cookies' => array(),
|
||||
'proxy' => array(),
|
||||
'auth' => array()
|
||||
|
@ -722,19 +723,50 @@ class HttpSocketTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestWithRedirect() {
|
||||
public function testRequestWithRedirectAsTrue() {
|
||||
$request = array(
|
||||
'uri' => 'http://localhost/oneuri'
|
||||
'uri' => 'http://localhost/oneuri',
|
||||
'redirect' => true
|
||||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
$this->Socket->config['redirect'] = true;
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals('<h1>You have been redirected</h1>', $response->body());
|
||||
}
|
||||
|
||||
public function testRequestWithRedirectAsInt() {
|
||||
$request = array(
|
||||
'uri' => 'http://localhost/oneuri',
|
||||
'redirect' => 2
|
||||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n<h1>You have been redirected</h1>";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals(1, $this->Socket->request['redirect']);
|
||||
}
|
||||
|
||||
public function testRequestWithRedirectAsIntReachingZero() {
|
||||
$request = array(
|
||||
'uri' => 'http://localhost/oneuri',
|
||||
'redirect' => 1
|
||||
);
|
||||
$serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n";
|
||||
$serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n";
|
||||
$this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse1));
|
||||
$this->Socket->expects($this->at(4))->method('read')->will($this->returnValue($serverResponse2));
|
||||
|
||||
$response = $this->Socket->request($request);
|
||||
$this->assertEquals(0, $this->Socket->request['redirect']);
|
||||
$this->assertEquals(302, $response->code);
|
||||
$this->assertEquals('http://localhost/anotheruri', $response->getHeader('Location'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testProxy method
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
App::uses('Dispatcher', 'Routing');
|
||||
|
||||
if (!class_exists('AppController', false)) {
|
||||
require_once CAKE . 'Controller' . DS . 'AppController.php';
|
||||
require_once CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS . 'AppController.php';
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')){
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
|
@ -1206,7 +1206,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
public static function assetProvider() {
|
||||
return array(
|
||||
array(
|
||||
'theme/test_theme/flash/theme_test.swf',
|
||||
'theme/test_theme/flash/theme_test.swf',
|
||||
'View/Themed/TestTheme/webroot/flash/theme_test.swf'
|
||||
),
|
||||
array(
|
||||
|
@ -1369,7 +1369,7 @@ class DispatcherTest extends CakeTestCase {
|
|||
array('test_cached_pages/themed'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testFullPageCachingDispatch method
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue