Commit 873b2b04 by Carsten Brandt

fixed test breaks after #3614

parent 0f481700
...@@ -145,8 +145,8 @@ class SortTest extends TestCase ...@@ -145,8 +145,8 @@ class SortTest extends TestCase
'route' => 'site/index', 'route' => 'site/index',
]); ]);
$this->assertEquals('/index.php?r=site/index&sort=-age%2C-name', $sort->createUrl('age')); $this->assertEquals('/index.php?r=site%2Findex&sort=-age%2C-name', $sort->createUrl('age'));
$this->assertEquals('/index.php?r=site/index&sort=name%2Cage', $sort->createUrl('name')); $this->assertEquals('/index.php?r=site%2Findex&sort=name%2Cage', $sort->createUrl('name'));
} }
public function testLink() public function testLink()
...@@ -173,6 +173,6 @@ class SortTest extends TestCase ...@@ -173,6 +173,6 @@ class SortTest extends TestCase
'route' => 'site/index', 'route' => 'site/index',
]); ]);
$this->assertEquals('<a class="asc" href="/index.php?r=site/index&amp;sort=-age%2C-name" data-sort="-age,-name">Age</a>', $sort->link('age')); $this->assertEquals('<a class="asc" href="/index.php?r=site%2Findex&amp;sort=-age%2C-name" data-sort="-age,-name">Age</a>', $sort->link('age'));
} }
} }
...@@ -10,6 +10,9 @@ namespace yiiunit\framework\helpers; ...@@ -10,6 +10,9 @@ namespace yiiunit\framework\helpers;
use yiiunit\TestCase; use yiiunit\TestCase;
use yii\helpers\Security; use yii\helpers\Security;
/**
* @group helpers
*/
class SecurityTest extends TestCase class SecurityTest extends TestCase
{ {
public function testPasswordHash() public function testPasswordHash()
......
...@@ -9,6 +9,7 @@ use yiiunit\TestCase; ...@@ -9,6 +9,7 @@ use yiiunit\TestCase;
/** /**
* UrlTest * UrlTest
* @group helpers
*/ */
class UrlTest extends TestCase class UrlTest extends TestCase
{ {
...@@ -21,7 +22,7 @@ class UrlTest extends TestCase ...@@ -21,7 +22,7 @@ class UrlTest extends TestCase
'class' => 'yii\web\Request', 'class' => 'yii\web\Request',
'scriptUrl' => '/base/index.php', 'scriptUrl' => '/base/index.php',
'hostInfo' => 'http://example.com/', 'hostInfo' => 'http://example.com/',
'url' => '/base/index.php&r=site/current&id=42' 'url' => '/base/index.php&r=site%2Fcurrent&id=42'
], ],
], ],
], '\yii\web\Application'); ], '\yii\web\Application');
...@@ -56,24 +57,24 @@ class UrlTest extends TestCase ...@@ -56,24 +57,24 @@ class UrlTest extends TestCase
$this->mockAction('page', 'view', null, ['id' => 10]); $this->mockAction('page', 'view', null, ['id' => 10]);
// If the route is an empty string, the current route will be used; // If the route is an empty string, the current route will be used;
$this->assertEquals('/base/index.php?r=page/view', Url::toRoute('')); $this->assertEquals('/base/index.php?r=page%2Fview', Url::toRoute(''));
$this->assertEquals('http://example.com/base/index.php?r=page/view', Url::toRoute('', true)); $this->assertEquals('http://example.com/base/index.php?r=page%2Fview', Url::toRoute('', true));
$this->assertEquals('https://example.com/base/index.php?r=page/view', Url::toRoute('', 'https')); $this->assertEquals('https://example.com/base/index.php?r=page%2Fview', Url::toRoute('', 'https'));
// If the route contains no slashes at all, it is considered to be an action ID of the current controller and // If the route contains no slashes at all, it is considered to be an action ID of the current controller and
// will be prepended with uniqueId; // will be prepended with uniqueId;
$this->assertEquals('/base/index.php?r=page/edit', Url::toRoute('edit')); $this->assertEquals('/base/index.php?r=page%2Fedit', Url::toRoute('edit'));
$this->assertEquals('/base/index.php?r=page/edit&id=20', Url::toRoute(['edit', 'id' => 20])); $this->assertEquals('/base/index.php?r=page%2Fedit&id=20', Url::toRoute(['edit', 'id' => 20]));
$this->assertEquals('http://example.com/base/index.php?r=page/edit&id=20', Url::toRoute(['edit', 'id' => 20], true)); $this->assertEquals('http://example.com/base/index.php?r=page%2Fedit&id=20', Url::toRoute(['edit', 'id' => 20], true));
$this->assertEquals('https://example.com/base/index.php?r=page/edit&id=20', Url::toRoute(['edit', 'id' => 20], 'https')); $this->assertEquals('https://example.com/base/index.php?r=page%2Fedit&id=20', Url::toRoute(['edit', 'id' => 20], 'https'));
// If the route has no leading slash, it is considered to be a route relative // If the route has no leading slash, it is considered to be a route relative
// to the current module and will be prepended with the module's uniqueId. // to the current module and will be prepended with the module's uniqueId.
$this->mockAction('default', 'index', 'stats'); $this->mockAction('default', 'index', 'stats');
$this->assertEquals('/base/index.php?r=stats/user/view', Url::toRoute('user/view')); $this->assertEquals('/base/index.php?r=stats%2Fuser%2Fview', Url::toRoute('user/view'));
$this->assertEquals('/base/index.php?r=stats/user/view&id=42', Url::toRoute(['user/view', 'id' => 42])); $this->assertEquals('/base/index.php?r=stats%2Fuser%2Fview&id=42', Url::toRoute(['user/view', 'id' => 42]));
$this->assertEquals('http://example.com/base/index.php?r=stats/user/view&id=42', Url::toRoute(['user/view', 'id' => 42], true)); $this->assertEquals('http://example.com/base/index.php?r=stats%2Fuser%2Fview&id=42', Url::toRoute(['user/view', 'id' => 42], true));
$this->assertEquals('https://example.com/base/index.php?r=stats/user/view&id=42', Url::toRoute(['user/view', 'id' => 42], 'https')); $this->assertEquals('https://example.com/base/index.php?r=stats%2Fuser%2Fview&id=42', Url::toRoute(['user/view', 'id' => 42], 'https'));
// In case there is no controller, an exception should be thrown for relative route // In case there is no controller, an exception should be thrown for relative route
$this->removeMockedAction(); $this->removeMockedAction();
...@@ -87,23 +88,23 @@ class UrlTest extends TestCase ...@@ -87,23 +88,23 @@ class UrlTest extends TestCase
// is an array: the first array element is considered a route, while the rest of the name-value // is an array: the first array element is considered a route, while the rest of the name-value
// pairs are treated as the parameters to be used for URL creation using Url::toRoute. // pairs are treated as the parameters to be used for URL creation using Url::toRoute.
$this->mockAction('page', 'view', null, ['id' => 10]); $this->mockAction('page', 'view', null, ['id' => 10]);
$this->assertEquals('/base/index.php?r=page/edit&id=20', Url::to(['edit', 'id' => 20])); $this->assertEquals('/base/index.php?r=page%2Fedit&id=20', Url::to(['edit', 'id' => 20]));
$this->assertEquals('/base/index.php?r=page/edit', Url::to(['edit'])); $this->assertEquals('/base/index.php?r=page%2Fedit', Url::to(['edit']));
$this->assertEquals('/base/index.php?r=page/view', Url::to([''])); $this->assertEquals('/base/index.php?r=page%2Fview', Url::to(['']));
$this->assertEquals('http://example.com/base/index.php?r=page/edit&id=20', Url::to(['edit', 'id' => 20], true)); $this->assertEquals('http://example.com/base/index.php?r=page%2Fedit&id=20', Url::to(['edit', 'id' => 20], true));
$this->assertEquals('http://example.com/base/index.php?r=page/edit', Url::to(['edit'], true)); $this->assertEquals('http://example.com/base/index.php?r=page%2Fedit', Url::to(['edit'], true));
$this->assertEquals('http://example.com/base/index.php?r=page/view', Url::to([''], true)); $this->assertEquals('http://example.com/base/index.php?r=page%2Fview', Url::to([''], true));
$this->assertEquals('https://example.com/base/index.php?r=page/edit&id=20', Url::to(['edit', 'id' => 20], 'https')); $this->assertEquals('https://example.com/base/index.php?r=page%2Fedit&id=20', Url::to(['edit', 'id' => 20], 'https'));
$this->assertEquals('https://example.com/base/index.php?r=page/edit', Url::to(['edit'], 'https')); $this->assertEquals('https://example.com/base/index.php?r=page%2Fedit', Url::to(['edit'], 'https'));
$this->assertEquals('https://example.com/base/index.php?r=page/view', Url::to([''], 'https')); $this->assertEquals('https://example.com/base/index.php?r=page%2Fview', Url::to([''], 'https'));
// is an empty string: the currently requested URL will be returned; // is an empty string: the currently requested URL will be returned;
$this->mockAction('page', 'view', null, ['id' => 10]); $this->mockAction('page', 'view', null, ['id' => 10]);
$this->assertEquals('/base/index.php&r=site/current&id=42', Url::to('')); $this->assertEquals('/base/index.php&r=site%2Fcurrent&id=42', Url::to(''));
$this->assertEquals('http://example.com/base/index.php&r=site/current&id=42', Url::to('', true)); $this->assertEquals('http://example.com/base/index.php&r=site%2Fcurrent&id=42', Url::to('', true));
$this->assertEquals('https://example.com/base/index.php&r=site/current&id=42', Url::to('', 'https')); $this->assertEquals('https://example.com/base/index.php&r=site%2Fcurrent&id=42', Url::to('', 'https'));
// is a non-empty string: it will first be processed by [[Yii::getAlias()]]. If the result // is a non-empty string: it will first be processed by [[Yii::getAlias()]]. If the result
// is an absolute URL, it will be returned either without any change or, if schema was specified, with schema // is an absolute URL, it will be returned either without any change or, if schema was specified, with schema
...@@ -122,9 +123,9 @@ class UrlTest extends TestCase ...@@ -122,9 +123,9 @@ class UrlTest extends TestCase
$this->assertEquals('http://example.com/base/test/me2', Url::to('@web2', true)); $this->assertEquals('http://example.com/base/test/me2', Url::to('@web2', true));
$this->assertEquals('https://example.com/base/test/me2', Url::to('@web2', 'https')); $this->assertEquals('https://example.com/base/test/me2', Url::to('@web2', 'https'));
$this->assertEquals('/base/index.php&r=site/current&id=42', Url::to('@web3')); $this->assertEquals('/base/index.php&r=site%2Fcurrent&id=42', Url::to('@web3'));
$this->assertEquals('http://example.com/base/index.php&r=site/current&id=42', Url::to('@web3', true)); $this->assertEquals('http://example.com/base/index.php&r=site%2Fcurrent&id=42', Url::to('@web3', true));
$this->assertEquals('https://example.com/base/index.php&r=site/current&id=42', Url::to('@web3', 'https')); $this->assertEquals('https://example.com/base/index.php&r=site%2Fcurrent&id=42', Url::to('@web3', 'https'));
$this->assertEquals('/test', Url::to('@web4')); $this->assertEquals('/test', Url::to('@web4'));
$this->assertEquals('http://example.com/test', Url::to('@web4', true)); $this->assertEquals('http://example.com/test', Url::to('@web4', true));
...@@ -159,7 +160,7 @@ class UrlTest extends TestCase ...@@ -159,7 +160,7 @@ class UrlTest extends TestCase
public function testCanonical() public function testCanonical()
{ {
$this->mockAction('page', 'view', null, ['id' => 10]); $this->mockAction('page', 'view', null, ['id' => 10]);
$this->assertEquals('http://example.com/base/index.php?r=page/view&id=10', Url::canonical()); $this->assertEquals('http://example.com/base/index.php?r=page%2Fview&id=10', Url::canonical());
$this->removeMockedAction(); $this->removeMockedAction();
} }
} }
...@@ -24,9 +24,9 @@ class UrlManagerTest extends TestCase ...@@ -24,9 +24,9 @@ class UrlManagerTest extends TestCase
'cache' => null, 'cache' => null,
]); ]);
$url = $manager->createUrl(['post/view']); $url = $manager->createUrl(['post/view']);
$this->assertEquals('?r=post/view', $url); $this->assertEquals('?r=post%2Fview', $url);
$url = $manager->createUrl(['post/view', 'id' => 1, 'title' => 'sample post']); $url = $manager->createUrl(['post/view', 'id' => 1, 'title' => 'sample post']);
$this->assertEquals('?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('?r=post%2Fview&id=1&title=sample+post', $url);
// default setting with '/test/' as base url // default setting with '/test/' as base url
$manager = new UrlManager([ $manager = new UrlManager([
...@@ -34,7 +34,7 @@ class UrlManagerTest extends TestCase ...@@ -34,7 +34,7 @@ class UrlManagerTest extends TestCase
'cache' => null, 'cache' => null,
]); ]);
$url = $manager->createUrl(['post/view', 'id' => 1, 'title' => 'sample post']); $url = $manager->createUrl(['post/view', 'id' => 1, 'title' => 'sample post']);
$this->assertEquals('/test?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('/test?r=post%2Fview&id=1&title=sample+post', $url);
// pretty URL without rules // pretty URL without rules
$manager = new UrlManager([ $manager = new UrlManager([
...@@ -123,14 +123,14 @@ class UrlManagerTest extends TestCase ...@@ -123,14 +123,14 @@ class UrlManagerTest extends TestCase
'cache' => null, 'cache' => null,
]); ]);
$url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post']); $url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post']);
$this->assertEquals('http://www.example.com?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('http://www.example.com?r=post%2Fview&id=1&title=sample+post', $url);
$url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post'], 'https'); $url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post'], 'https');
$this->assertEquals('https://www.example.com?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('https://www.example.com?r=post%2Fview&id=1&title=sample+post', $url);
$manager->hostInfo = 'https://www.example.com'; $manager->hostInfo = 'https://www.example.com';
$url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post'], 'http'); $url = $manager->createAbsoluteUrl(['post/view', 'id' => 1, 'title' => 'sample post'], 'http');
$this->assertEquals('http://www.example.com?r=post/view&id=1&title=sample+post', $url); $this->assertEquals('http://www.example.com?r=post%2Fview&id=1&title=sample+post', $url);
} }
public function testParseRequest() public function testParseRequest()
......
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