Commit 7f1b8c10 by Qiang Xue

Adjust for test integration.

parent 4e1fc27f
<?php
$I = new TestGuy($scenario);
$I->wantTo('ensure that about works');
$I->amOnPage('?r=site/about');
$I->see('About', 'h1');
......@@ -65,7 +65,7 @@ class YiiBase
* @var boolean whether to search PHP include_path when autoloading unknown classes.
* You may want to turn this off if you are also using autoloaders from other libraries.
*/
public static $enableIncludePath = true;
public static $enableIncludePath = false;
/**
* @var \yii\console\Application|\yii\web\Application the application instance
*/
......
......@@ -35,7 +35,7 @@ class Response extends \yii\base\Response
* @event ResponseEvent an event that is triggered right after [[prepare()]] is called in [[send()]].
* You may respond to this event to filter the response content before it is sent to the client.
*/
const EVENT_PREPARE = 'prepare';
const EVENT_AFTER_PREPARE = 'afterPrepare';
const FORMAT_RAW = 'raw';
const FORMAT_HTML = 'html';
......@@ -218,6 +218,11 @@ class Response extends \yii\base\Response
*/
public function setStatusCode($value, $text = null)
{
if ($value === null) {
$this->_statusCode = null;
$this->statusText = null;
return;
}
$this->_statusCode = (int)$value;
if ($this->getIsInvalid()) {
throw new InvalidParamException("The HTTP status code is invalid: $value");
......@@ -249,7 +254,7 @@ class Response extends \yii\base\Response
{
$this->trigger(self::EVENT_BEFORE_SEND, new ResponseEvent($this));
$this->prepare();
$this->trigger(self::EVENT_PREPARE, new ResponseEvent($this));
$this->trigger(self::EVENT_AFTER_PREPARE, new ResponseEvent($this));
$this->sendHeaders();
$this->sendContent();
$this->trigger(self::EVENT_AFTER_SEND, new ResponseEvent($this));
......@@ -319,14 +324,8 @@ class Response extends \yii\base\Response
*/
protected function sendContent()
{
if (is_array($this->content)) {
echo 'array()';
} elseif (is_object($this->content)) {
echo method_exists($this->content, '__toString') ? (string)$this->content : get_class($this->content);
} else {
echo $this->content;
}
}
/**
* Sends a file to the browser.
......@@ -721,12 +720,10 @@ class Response extends \yii\base\Response
}
if ($formatter instanceof ResponseFormatter) {
$formatter->format($this);
return;
} else {
throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatter interface.");
}
}
} else {
switch ($this->format) {
case self::FORMAT_HTML:
$this->getHeaders()->setDefault('Content-Type', 'text/html; charset=' . $this->charset);
......@@ -755,4 +752,11 @@ class Response extends \yii\base\Response
throw new InvalidConfigException("Unsupported response format: {$this->format}");
}
}
if (is_array($this->content)) {
$this->content = 'array()';
} elseif (is_object($this->content)) {
$this->content = method_exists($this->content, '__toString') ? (string)$this->content : get_class($this->content);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment