Commit 386b63b4 by Alexander Makarov

Merge branch 'master' into codeception-test-adjustments

Conflicts: .travis.yml
parents 7eb403bf cc1247f3
......@@ -47,8 +47,13 @@ before_script:
script:
- vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --exclude-group mssql,oci,wincache,xcache,zenddata
- cd apps/basic/tests && php ../vendor/bin/codecept run
- cd ../../advanced/tests && ../vendor/bin/codecept run
- |
if (php --version | grep -i HipHop > /dev/null); then
echo "skipping application tests on HHVM"
else
cd apps/basic/tests && php ../vendor/bin/codecept run
cd ../../advanced/tests && ../vendor/bin/codecept run
fi
after_script:
- cd ../../..
......
......@@ -23,17 +23,17 @@ class ClassmapController extends Controller
/**
* Creates a class map for the core Yii classes.
* @param string $root the root path of Yii framework. Defaults to YII_PATH.
* @param string $mapFile the file to contain the class map. Defaults to YII_PATH . '/classes.php'.
* @param string $root the root path of Yii framework. Defaults to YII2_PATH.
* @param string $mapFile the file to contain the class map. Defaults to YII2_PATH . '/classes.php'.
*/
public function actionCreate($root = null, $mapFile = null)
{
if ($root === null) {
$root = YII_PATH;
$root = YII2_PATH;
}
$root = FileHelper::normalizePath($root);
if ($mapFile === null) {
$mapFile = YII_PATH . '/classes.php';
$mapFile = YII2_PATH . '/classes.php';
}
$options = [
'filter' => function ($path) {
......@@ -60,7 +60,7 @@ class ClassmapController extends Controller
throw new Exception("Something wrong: $file\n");
}
$path = str_replace('\\', '/', substr($file, strlen($root)));
$map[$path] = " 'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII_PATH . '$path',";
$map[$path] = " 'yii" . substr(str_replace('/', '\\', $path), 0, -4) . "' => YII2_PATH . '$path',";
}
ksort($map);
$map = implode("\n", $map);
......
......@@ -37,7 +37,7 @@ class PhpDocController extends Controller
*
* See https://github.com/yiisoft/yii2/wiki/Core-framework-code-style#documentation for details.
*
* @param string $root the directory to parse files from. Defaults to YII_PATH.
* @param string $root the directory to parse files from. Defaults to YII2_PATH.
*/
public function actionProperty($root = null)
{
......@@ -68,7 +68,7 @@ class PhpDocController extends Controller
/**
* Fix some issues with PHPdoc in files
*
* @param string $root the directory to parse files from. Defaults to YII_PATH.
* @param string $root the directory to parse files from. Defaults to YII2_PATH.
*/
public function actionFix($root = null)
{
......@@ -112,7 +112,7 @@ class PhpDocController extends Controller
{
$except = [];
if ($root === null) {
$root = dirname(YII_PATH);
$root = dirname(YII2_PATH);
$extensionPath = "$root/extensions";
foreach (scandir($extensionPath) as $extension) {
if (ctype_alpha($extension) && is_dir($extensionPath . '/' . $extension)) {
......
......@@ -79,7 +79,7 @@ class ReleaseController extends Controller
protected function getChangelogs()
{
return array_merge([YII_PATH . '/CHANGELOG.md'], glob(dirname(YII_PATH) . '/extensions/*/CHANGELOG.md'));
return array_merge([YII2_PATH . '/CHANGELOG.md'], glob(dirname(YII2_PATH) . '/extensions/*/CHANGELOG.md'));
}
protected function composerSetStability($version)
......@@ -99,9 +99,9 @@ class ReleaseController extends Controller
'/"minimum-stability": "(.+?)",/',
'"minimum-stability": "' . $stability . '",',
[
dirname(YII_PATH) . '/apps/advanced/composer.json',
dirname(YII_PATH) . '/apps/basic/composer.json',
dirname(YII_PATH) . '/apps/benchmark/composer.json',
dirname(YII2_PATH) . '/apps/advanced/composer.json',
dirname(YII2_PATH) . '/apps/basic/composer.json',
dirname(YII2_PATH) . '/apps/benchmark/composer.json',
]
);
}
......@@ -111,7 +111,7 @@ class ReleaseController extends Controller
$this->sed(
'/function getVersion\(\)\n \{\n return \'(.+?)\';/',
"function getVersion()\n {\n return '$version';",
YII_PATH . '/BaseYii.php');
YII2_PATH . '/BaseYii.php');
}
protected function sed($pattern, $replace, $files)
......
......@@ -103,7 +103,9 @@ Configuring Web Servers <a name="configuring-web-servers"></a>
The application installed according to the above instructions should work out of box with either
an [Apache HTTP server](http://httpd.apache.org/) or an [Nginx HTTP server](http://nginx.org/), on
Windows, Mac OS X, or Linux.
Windows, Mac OS X, or Linux running PHP 5.4 or higher. Yii 2.0 is also compatible the facebooks
[HHVM](http://hhvm.com/) however there are some edge cases where HHVM behaves different than native
PHP so you have to take some extra care when using HHVM.
On a production server, you may want to configure your Web server so that the application can be accessed
via the URL `http://www.example.com/index.php` instead of `http://www.example.com/basic/web/index.php`. Such configuration
......
......@@ -121,7 +121,7 @@ class BaseDoc extends Object
//
// public function getSourceCode()
// {
// $lines = file(YII_PATH . $this->sourcePath);
// $lines = file(YII2_PATH . $this->sourcePath);
// return implode("", array_slice($lines, $this->startLine - 1, $this->endLine - $this->startLine + 1));
// }
......
......@@ -20,7 +20,7 @@ defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME', microtime(true));
/**
* This constant defines the framework installation directory.
*/
defined('YII_PATH') or define('YII_PATH', __DIR__);
defined('YII2_PATH') or define('YII2_PATH', __DIR__);
/**
* This constant defines whether the application should be in debug mode or not. Defaults to false.
*/
......
......@@ -180,6 +180,7 @@ Yii Framework 2 Change Log
- Enh #4602: Added $key param in ActionColumn buttons Closure call (disem)
- Enh #4607: AR model will throw an exception if it does not have a primary key to avoid updating/deleting data massively (qiangxue)
- Enh #4630: Added automatic generating of unique slug value to `yii\behaviors\Sluggable` (klimov-paul)
- Enh #4636: Added `yii\web\Response::setDownloadHeaders()` (pawzar)
- Enh #4644: Added `\yii\db\Schema::createColumnSchema()` to be able to customize column schema used (mcd-php)
- Enh #4656: HtmlPurifier helper config can now be a closure to change the purifier config object after it was created (Alex-Code)
- Enh #4691: Encoding on `ActiveForm` and `ActiveField` validation errors is now configurable (Alex-Code)
......@@ -228,6 +229,7 @@ Yii Framework 2 Change Log
- Chg #4310: Removed `$data` from signature of `yii\rbac\ManagerInterface` (samdark)
- Chg #4318: `yii\helpers\Html::ul()` and `ol()` will return an empty list tag if an empty item array is given (qiangxue)
- Chg #4331: `yii\helpers\Url` now uses `UrlManager` to determine base URL when generating URLs (qiangxue)
- Chg #4501: Renamed the constant `YII_PATH` to `YII2_PATH` (qiangxue)
- Chg #4586: Signed bigint and unsigned int will be converted into integers when they are loaded from DB by AR (qiangxue)
- Chg #4591: `yii\helpers\Url::to()` will no longer prefix relative URLs with the base URL (qiangxue)
- Chg #4595: `yii\widgets\LinkPager`'s `nextPageLabel`, `prevPageLabel`, `firstPageLabel`, `lastPageLabel` are now taking `false` instead of `null` for "no label" (samdark)
......
......@@ -78,6 +78,8 @@ Upgrade from Yii 2.0 Beta
`new \yii\caching\TagDependency(['tags' => 'TagName'])`, where `TagName` is similar to the group name that you
previously used.
* If you are using the constant `YII_PATH` in your code, you should rename it to `YII2_PATH` now.
* You must explicitly configure `yii\web\Request::cookieValidationKey` with a secret key. Previously this is done automatically.
To do so, modify your application configuration like the following:
......
{
"name": "yii2",
"version": "2.0.0",
"homepage": "http://www.yiiframework.com/",
"authors": [
"Qiang Xue <qiang.xue@gmail.com>",
"Alexander Makarov <sam@rmcreative.ru>",
"Carsten Brandt <mail@cebe.cc>",
"Paul Klimov <klimov.paul@gmail.com>"
],
"description": "Yii PHP Framework Version 2",
"keywords": [
"yii2",
"framework"
],
"license": "BSD-3-Clause",
"main": [
"assets/yii.js",
"assets/yii.validation.js",
"assets/yii.activeForm.js",
"assets/yii.captcha.js",
"assets/yii.gridView.js"
],
"ignore": [
"**/.*",
"**/*",
"!assets/",
"!LICENSE.md"
],
"dependencies": {
"jquery.inputmask": ">=3.0.0",
"punycode": ">=1.3.0"
}
}
......@@ -249,7 +249,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a decimal number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
......@@ -267,7 +267,7 @@ class Formatter extends \yii\base\Formatter
* @param mixed $value the value to be formatted
* @param string $currency the 3-letter ISO 4217 currency code indicating the currency to use.
* If null, [[currencyCode]] will be used.
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
......@@ -287,7 +287,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a percent number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
......@@ -303,7 +303,7 @@ class Formatter extends \yii\base\Formatter
/**
* Formats the value as a scientific number.
* @param mixed $value the value to be formatted
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* for details on how to specify a format.
* @return string the formatted result.
*/
......@@ -319,7 +319,7 @@ class Formatter extends \yii\base\Formatter
/**
* Creates a number formatter based on the given type and format.
* @param integer $type the type of the number formatter
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details)
* @param string $format the format to be used. Please refer to [ICU manual](http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#details)
* @return NumberFormatter the created formatter instance
*/
protected function createNumberFormatter($type, $format)
......
......@@ -141,7 +141,7 @@ class Logger extends Component
$ts = debug_backtrace();
array_pop($ts); // remove the last trace since it would be the entry script, not very useful
foreach ($ts as $trace) {
if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII_PATH) !== 0) {
if (isset($trace['file'], $trace['line']) && strpos($trace['file'], YII2_PATH) !== 0) {
unset($trace['object'], $trace['args']);
$traces[] = $trace;
if (++$count >= $this->traceLevel) {
......
......@@ -23,6 +23,9 @@ use yii\helpers\VarDumper;
* (for example, the authorization data for a personal blog system).
* Use [[DbManager]] for more complex authorization data.
*
* Note that PhpManager is not compatible with facebooks [HHVM](http://hhvm.com/) because
* it relies on writing php files and including them afterwards which is not supported by HHVM.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Alexander Kochetov <creocoder@gmail.com>
* @author Christophe Boulain <christophe.boulain@gmail.com>
......
......@@ -278,7 +278,7 @@ class ErrorHandler extends \yii\base\ErrorHandler
*/
public function isCoreFile($file)
{
return $file === null || strpos(realpath($file), YII_PATH . DIRECTORY_SEPARATOR) === 0;
return $file === null || strpos(realpath($file), YII2_PATH . DIRECTORY_SEPARATOR) === 0;
}
/**
......
......@@ -455,24 +455,19 @@ class Response extends \yii\base\Response
public function sendContentAsFile($content, $attachmentName, $mimeType = 'application/octet-stream')
{
$headers = $this->getHeaders();
$contentLength = StringHelper::byteLength($content);
$range = $this->getHttpRange($contentLength);
if ($range === false) {
$headers->set('Content-Range', "bytes */$contentLength");
throw new HttpException(416, 'Requested range not satisfiable');
}
$headers->setDefault('Pragma', 'public')
->setDefault('Accept-Ranges', 'bytes')
->setDefault('Expires', '0')
->setDefault('Content-Type', $mimeType)
->setDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->setDefault('Content-Transfer-Encoding', 'binary')
->setDefault('Content-Length', StringHelper::byteLength($content))
->setDefault('Content-Disposition', "attachment; filename=\"$attachmentName\"");
$this->setDownloadHeaders($attachmentName, $mimeType, $contentLength);
list($begin, $end) = $range;
if ($begin !=0 || $end != $contentLength - 1) {
if ($begin != 0 || $end != $contentLength - 1) {
$this->setStatusCode(206);
$headers->set('Content-Range', "bytes $begin-$end/$contentLength");
$this->content = StringHelper::byteSubstr($content, $begin, $end - $begin + 1);
......@@ -511,25 +506,46 @@ class Response extends \yii\base\Response
}
list($begin, $end) = $range;
if ($begin !=0 || $end != $fileSize - 1) {
if ($begin != 0 || $end != $fileSize - 1) {
$this->setStatusCode(206);
$headers->set('Content-Range', "bytes $begin-$end/$fileSize");
} else {
$this->setStatusCode(200);
}
$length = $end - $begin + 1;
$this->setDownloadHeaders($attachmentName, $mimeType, $end - $begin + 1);
$this->format = self::FORMAT_RAW;
$this->stream = [$handle, $begin, $end];
return $this;
}
/**
* Sets a default set of HTTP headers for file downloading purpose.
* @param string $attachmentName the attachment file name
* @param string $mimeType the MIME type for the response. If null, `Content-Type` header will NOT be set.
* @param integer $contentLength the byte length of the file being downloaded. If null, `Content-Length` header will NOT be set.
* @return static the response object itself
*/
public function setDownloadHeaders($attachmentName, $mimeType = null, $contentLength = null)
{
$headers = $this->getHeaders();
$headers->setDefault('Pragma', 'public')
->setDefault('Accept-Ranges', 'bytes')
->setDefault('Expires', '0')
->setDefault('Content-Type', $mimeType)
->setDefault('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->setDefault('Content-Transfer-Encoding', 'binary')
->setDefault('Content-Length', $length)
->setDefault('Content-Disposition', "attachment; filename=\"$attachmentName\"");
$this->format = self::FORMAT_RAW;
$this->stream = [$handle, $begin, $end];
if ($mimeType !== null) {
$headers->setDefault('Content-Type', $mimeType);
}
if ($contentLength !== null) {
$headers->setDefault('Content-Length', $contentLength);
}
return $this;
}
......
......@@ -2,7 +2,7 @@
#
# install CUBRID DBMS
if (php --version | grep -i HHVM > /dev/null); then
if (php --version | grep -i HipHop > /dev/null); then
echo "Skipping CUBRID on HHVM"
exit 0
fi
......
#!/bin/sh
if (php --version | grep -i HHVM > /dev/null); then
if (php --version | grep -i HipHop > /dev/null); then
echo "skipping application init on HHVM"
else
......
#!/bin/sh
if (php --version | grep -i HHVM > /dev/null); then
if (php --version | grep -i HipHop > /dev/null); then
echo "skipping memcache on HHVM"
else
mkdir -p ~/.phpenv/versions/$(phpenv version-name)/etc
......
#!/bin/sh
if (php --version | grep -i HHVM > /dev/null); then
if (php --version | grep -i HipHop > /dev/null); then
echo "skipping application setup on HHVM"
else
......
......@@ -26,7 +26,7 @@ class BaseYiiTest extends TestCase
public function testAlias()
{
$this->assertEquals(YII_PATH, Yii::getAlias('@yii'));
$this->assertEquals(YII2_PATH, Yii::getAlias('@yii'));
Yii::$aliases = [];
$this->assertFalse(Yii::getAlias('@yii', false));
......
......@@ -265,7 +265,10 @@ class FormatterTest extends TestCase
$this->assertSame('12 years ago', $this->formatter->asRelativeTime($interval_12_years));
// Pass a DateInterval string
$this->assertSame('a year ago', $this->formatter->asRelativeTime('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z'));
if (!defined('HHVM_VERSION')) {
// TODO format not supported by HHVM currently https://github.com/facebook/hhvm/issues/2952
$this->assertSame('a year ago', $this->formatter->asRelativeTime('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z'));
}
$this->assertSame('a year ago', $this->formatter->asRelativeTime('2007-03-01T13:00:00Z/P1Y2M10DT2H30M'));
$this->assertSame('a year ago', $this->formatter->asRelativeTime('P1Y2M10DT2H30M/2008-05-11T15:30:00Z'));
$this->assertSame('a year ago', $this->formatter->asRelativeTime('P1Y2M10DT2H30M'));
......@@ -324,7 +327,10 @@ class FormatterTest extends TestCase
$this->assertSame('in 12 years', $this->formatter->asRelativeTime($interval_12_years));
// Pass a inverted DateInterval string
$this->assertSame('in a year', $this->formatter->asRelativeTime('2008-05-11T15:30:00Z/2007-03-01T13:00:00Z'));
if (!defined('HHVM_VERSION')) {
// TODO format not supported by HHVM currently https://github.com/facebook/hhvm/issues/2952
$this->assertSame('in a year', $this->formatter->asRelativeTime('2008-05-11T15:30:00Z/2007-03-01T13:00:00Z'));
}
// Force the reference time and pass a future DateTime
$dateNow = new DateTime('2014-03-13');
......
......@@ -17,6 +17,11 @@ class POMessageControllerTest extends BaseMessageControllerTest
public function setUp()
{
parent::setUp();
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('POMessageControllerTest can not run on HHVM because it relies on saving and re-including PHP files which is not supported by HHVM.');
}
$this->messagePath = Yii::getAlias('@yiiunit/runtime/test_messages');
FileHelper::createDirectory($this->messagePath, 0777);
}
......
......@@ -188,7 +188,7 @@ class CommandTest extends DatabaseTestCase
$this->assertEquals($blobCol, stream_get_contents($row['blob_col']));
}
$this->assertEquals($numericCol, $row['numeric_col']);
if ($this->driverName === 'mysql') {
if ($this->driverName === 'mysql' || defined('HHVM_VERSION') && $this->driverName === 'sqlite') {
$this->assertEquals($boolCol, (int)$row['bool_col']);
} else {
$this->assertEquals($boolCol, $row['bool_col']);
......
......@@ -47,12 +47,19 @@ class FormatterTest extends TestCase
$value = '123456';
$this->assertSame("123,456", $this->formatter->asDecimal($value));
$value = '-123456.123';
$this->assertSame("-123,456.123", $this->formatter->asDecimal($value));
if (defined('HHVM_VERSION')) { // the default format is different on HHVM
$this->assertSame("-123,456", $this->formatter->asDecimal($value));
} else {
$this->assertSame("-123,456.123", $this->formatter->asDecimal($value));
}
$this->assertSame($this->formatter->nullDisplay, $this->formatter->asDecimal(null));
}
public function testAsPercent()
{
if (defined('HHVM_VERSION')) { // the default format is different on HHVM
$this->markTestSkipped('HHVM behaves quite different in the default patterns used for formatting.');
}
$value = '123';
$this->assertSame('12,300%', $this->formatter->asPercent($value));
$value = '0.1234';
......@@ -64,6 +71,9 @@ class FormatterTest extends TestCase
public function testAsScientific()
{
if (defined('HHVM_VERSION')) { // the default format is different on HHVM
$this->markTestSkipped('HHVM behaves quite different in the default patterns used for formatting.');
}
$value = '123';
$this->assertSame('1.23E2', $this->formatter->asScientific($value));
$value = '123456';
......
......@@ -384,6 +384,10 @@ class Message extends BaseMessage
public function toString()
{
return var_export($this, true);
$mailer = $this->mailer;
$this->mailer = null;
$s = var_export($this, true);
$this->mailer = $mailer;
return $s;
}
}
......@@ -72,6 +72,11 @@ class PhpManagerTest extends ManagerTestCase
static::$filemtime = null;
static::$time = null;
parent::setUp();
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('PhpManager is not compatible with HHVM.');
}
$this->mockApplication();
$this->removeDataFiles();
$this->auth = $this->createManager();
......
*
!.gitignore
!/coveralls/.gitkeep
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