Browse Source

Merge branch 'master' of git://github.com/yiisoft/yii2 into 13425-fix-url-rules-cache

tags/2.0.14
Yuriy Stovbur 8 years ago
parent
commit
4d7658ed71
  1. 12
      framework/messages/ru/yii.php
  2. 3
      framework/web/Controller.php
  3. 19
      tests/framework/web/ResponseTest.php

12
framework/messages/ru/yii.php

@ -92,12 +92,12 @@ return [
'{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать минимум {min, number} {min, plural, one{символ} few{символа} many{символов} other{символа}}.', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать минимум {min, number} {min, plural, one{символ} few{символа} many{символов} other{символа}}.',
'{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать максимум {max, number} {max, plural, one{символ} few{символа} many{символов} other{символа}}.', '{attribute} should contain at most {max, number} {max, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать максимум {max, number} {max, plural, one{символ} few{символа} many{символов} other{символа}}.',
'{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать {length, number} {length, plural, one{символ} few{символа} many{символов} other{символа}}.', '{attribute} should contain {length, number} {length, plural, one{character} other{characters}}.' => 'Значение «{attribute}» должно содержать {length, number} {length, plural, one{символ} few{символа} many{символов} other{символа}}.',
'{delta, plural, =1{1 day} other{# days}}' => '{delta, plural, one{# день} few{# дня} many{# дней} other{# дней}}', '{delta, plural, =1{1 day} other{# days}}' => '{delta, plural, one{# день} few{# дня} many{# дней} other{# дня}}',
'{delta, plural, =1{1 hour} other{# hours}}' => '{delta, plural, one{# час} few{# часа} many{# часов} other{# часов}}', '{delta, plural, =1{1 hour} other{# hours}}' => '{delta, plural, one{# час} few{# часа} many{# часов} other{# часа}}',
'{delta, plural, =1{1 minute} other{# minutes}}' => '{delta, plural, one{# минута} few{# минуты} many{# минут} other{# минут}}', '{delta, plural, =1{1 minute} other{# minutes}}' => '{delta, plural, one{# минута} few{# минуты} many{# минут} other{# минуты}}',
'{delta, plural, =1{1 month} other{# months}}' => '{delta, plural, one{# месяц} few{# месяца} many{# месяцев} other{# месяцев}}', '{delta, plural, =1{1 month} other{# months}}' => '{delta, plural, one{# месяц} few{# месяца} many{# месяцев} other{# месяца}}',
'{delta, plural, =1{1 second} other{# seconds}}' => '{delta, plural, one{# секунда} few{# секунды} many{# секунд} other{# секунд}}', '{delta, plural, =1{1 second} other{# seconds}}' => '{delta, plural, one{# секунда} few{# секунды} many{# секунд} other{# секунды}}',
'{delta, plural, =1{1 year} other{# years}}' => '{delta, plural, one{# год} few{# года} many{# лет} other{# лет}}', '{delta, plural, =1{1 year} other{# years}}' => '{delta, plural, one{# год} few{# года} many{# лет} other{# года}}',
'{delta, plural, =1{a day} other{# days}} ago' => '{delta, plural, =1{день} one{# день} few{# дня} many{# дней} other{# дня}} назад', '{delta, plural, =1{a day} other{# days}} ago' => '{delta, plural, =1{день} one{# день} few{# дня} many{# дней} other{# дня}} назад',
'{delta, plural, =1{a minute} other{# minutes}} ago' => '{delta, plural, =1{минуту} one{# минуту} few{# минуты} many{# минут} other{# минуты}} назад', '{delta, plural, =1{a minute} other{# minutes}} ago' => '{delta, plural, =1{минуту} one{# минуту} few{# минуты} many{# минут} other{# минуты}} назад',
'{delta, plural, =1{a month} other{# months}} ago' => '{delta, plural, =1{месяц} one{# месяц} few{# месяца} many{# месяцев} other{# месяца}} назад', '{delta, plural, =1{a month} other{# months}} ago' => '{delta, plural, =1{месяц} one{# месяц} few{# месяца} many{# месяцев} other{# месяца}} назад',

3
framework/web/Controller.php

@ -9,6 +9,7 @@ namespace yii\web;
use Yii; use Yii;
use yii\base\InlineAction; use yii\base\InlineAction;
use yii\helpers\Url;
/** /**
* Controller is the base class of web controllers. * Controller is the base class of web controllers.
@ -198,7 +199,7 @@ class Controller extends \yii\base\Controller
*/ */
public function redirect($url, $statusCode = 302) public function redirect($url, $statusCode = 302)
{ {
return Yii::$app->getResponse()->redirect($url, $statusCode); return Yii::$app->getResponse()->redirect(Url::to($url), $statusCode);
} }
/** /**

19
tests/framework/web/ResponseTest.php

@ -18,7 +18,7 @@ class ResponseTest extends \yiiunit\TestCase
protected function setUp() protected function setUp()
{ {
parent::setUp(); parent::setUp();
$this->mockApplication(); $this->mockWebApplication();
$this->response = new \yii\web\Response; $this->response = new \yii\web\Response;
} }
@ -101,4 +101,21 @@ class ResponseTest extends \yiiunit\TestCase
static::assertEquals('attachment; filename="test.txt"', $headers->get('Content-Disposition')); static::assertEquals('attachment; filename="test.txt"', $headers->get('Content-Disposition'));
static::assertEquals(4, $headers->get('Content-Length')); static::assertEquals(4, $headers->get('Content-Length'));
} }
public function testRedirect()
{
$_SERVER['REQUEST_URI'] = 'http://test-domain.com/';
$this->assertEquals($this->response->redirect('')->headers->get('location'), '/');
$this->assertEquals($this->response->redirect('http://some-external-domain.com')->headers->get('location'), 'http://some-external-domain.com');
$this->assertEquals($this->response->redirect('/')->headers->get('location'), '/');
$this->assertEquals($this->response->redirect('/something-relative')->headers->get('location'), '/something-relative');
$this->assertEquals($this->response->redirect(['/'])->headers->get('location'), '/index.php?r=');
$this->assertEquals($this->response->redirect(['view'])->headers->get('location'), '/index.php?r=view');
$this->assertEquals($this->response->redirect(['/controller'])->headers->get('location'), '/index.php?r=controller');
$this->assertEquals($this->response->redirect(['/controller/index'])->headers->get('location'), '/index.php?r=controller%2Findex');
$this->assertEquals($this->response->redirect(['//controller/index'])->headers->get('location'), '/index.php?r=controller%2Findex');
$this->assertEquals($this->response->redirect(['//controller/index', 'id' => 3])->headers->get('location'), '/index.php?r=controller%2Findex&id=3');
$this->assertEquals($this->response->redirect(['//controller/index', 'id_1' => 3, 'id_2' => 4])->headers->get('location'), '/index.php?r=controller%2Findex&id_1=3&id_2=4');
$this->assertEquals($this->response->redirect(['//controller/index', 'slug' => 'äöüß!"§$%&/()'])->headers->get('location'), '/index.php?r=controller%2Findex&slug=%C3%A4%C3%B6%C3%BC%C3%9F%21%22%C2%A7%24%25%26%2F%28%29');
}
} }

Loading…
Cancel
Save