Merge branch '2.0' of github.com:cakephp/cakephp into 2.0

This commit is contained in:
mark_story 2010-08-28 11:26:28 -04:00
commit 5257a66fe5
3 changed files with 7 additions and 13 deletions

View file

@ -392,10 +392,9 @@ class RequestHandlerComponent extends Component {
* types the client accepts. If a string is passed, returns true * types the client accepts. If a string is passed, returns true
* if the client accepts it. If an array is passed, returns true * if the client accepts it. If an array is passed, returns true
* if the client accepts one or more elements in the array. * if the client accepts one or more elements in the array.
* @access public
* @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::setContent()
*/ */
function accepts($type = null) { public function accepts($type = null) {
$accepted = $this->request->accepts(); $accepted = $this->request->accepts();
if ($type == null) { if ($type == null) {
@ -455,10 +454,9 @@ class RequestHandlerComponent extends Component {
* 'html', 'xml', 'js', etc. * 'html', 'xml', 'js', etc.
* @return mixed If $type is null or not provided, the first content-type in the * @return mixed If $type is null or not provided, the first content-type in the
* list, based on preference, is returned. * list, based on preference, is returned.
* @access public
* @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::setContent()
*/ */
function prefers($type = null) { public function prefers($type = null) {
$accepts = $this->accepts(); $accepts = $this->accepts();
if ($type == null) { if ($type == null) {
@ -480,7 +478,6 @@ class RequestHandlerComponent extends Component {
return ($types[0] == $accepts[0]); return ($types[0] == $accepts[0]);
} }
$intersect = array_values(array_intersect($accepts, $types)); $intersect = array_values(array_intersect($accepts, $types));
if (empty($intersect)) { if (empty($intersect)) {
return false; return false;
@ -494,11 +491,10 @@ class RequestHandlerComponent extends Component {
* @param object $controller A reference to a controller object * @param object $controller A reference to a controller object
* @param string $type Type of response to send (e.g: 'ajax') * @param string $type Type of response to send (e.g: 'ajax')
* @return void * @return void
* @access public
* @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::setContent()
* @see RequestHandlerComponent::respondAs() * @see RequestHandlerComponent::respondAs()
*/ */
function renderAs(&$controller, $type) { public function renderAs(&$controller, $type) {
$options = array('charset' => 'UTF-8'); $options = array('charset' => 'UTF-8');
if (Configure::read('App.encoding') !== null) { if (Configure::read('App.encoding') !== null) {
@ -548,10 +544,9 @@ class RequestHandlerComponent extends Component {
* @return boolean Returns false if the friendly type name given in $type does * @return boolean Returns false if the friendly type name given in $type does
* not exist in the type map, or if the Content-type header has * not exist in the type map, or if the Content-type header has
* already been set by this method. * already been set by this method.
* @access public
* @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::setContent()
*/ */
function respondAs($type, $options = array()) { public function respondAs($type, $options = array()) {
$defaults = array('index' => null, 'charset' => null, 'attachment' => false); $defaults = array('index' => null, 'charset' => null, 'attachment' => false);
$options = $options + $defaults; $options = $options + $defaults;
@ -629,5 +624,4 @@ class RequestHandlerComponent extends Component {
} }
return null; return null;
} }
} }

View file

@ -60,12 +60,12 @@ class PagesControllerTest extends CakeTestCase {
$Pages->viewPath = 'posts'; $Pages->viewPath = 'posts';
$Pages->display('index'); $Pages->display('index');
$this->assertPattern('/posts index/', $Pages->output); $this->assertPattern('/posts index/', $Pages->getResponse()->body());
$this->assertEqual($Pages->viewVars['page'], 'index'); $this->assertEqual($Pages->viewVars['page'], 'index');
$Pages->viewPath = 'themed'; $Pages->viewPath = 'themed';
$Pages->display('test_theme', 'posts', 'index'); $Pages->display('test_theme', 'posts', 'index');
$this->assertPattern('/posts index themed view/', $Pages->output); $this->assertPattern('/posts index themed view/', $Pages->getResponse()->body());
$this->assertEqual($Pages->viewVars['page'], 'test_theme'); $this->assertEqual($Pages->viewVars['page'], 'test_theme');
$this->assertEqual($Pages->viewVars['subpage'], 'posts'); $this->assertEqual($Pages->viewVars['subpage'], 'posts');
} }

View file

@ -789,7 +789,7 @@ class ScaffoldTest extends CakeTestCase {
$this->Controller->theme = 'test_theme'; $this->Controller->theme = 'test_theme';
$this->Controller->view = 'Theme'; $this->Controller->view = 'Theme';
$this->Controller->constructClasses(); $this->Controller->constructClasses();
$Scaffold =& new TestScaffoldMock($this->Controller, array()); $Scaffold =& new TestScaffoldMock($this->Controller, new CakeRequest());
$this->assertEqual($this->Controller->view, 'Scaffold'); $this->assertEqual($this->Controller->view, 'Scaffold');
} }