Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
873b2b04
Commit
873b2b04
authored
May 28, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test breaks after #3614
parent
0f481700
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
37 deletions
+41
-37
SortTest.php
tests/unit/framework/data/SortTest.php
+3
-3
SecurityTest.php
tests/unit/framework/helpers/SecurityTest.php
+3
-0
UrlTest.php
tests/unit/framework/helpers/UrlTest.php
+29
-28
UrlManagerTest.php
tests/unit/framework/web/UrlManagerTest.php
+6
-6
No files found.
tests/unit/framework/data/SortTest.php
View file @
873b2b04
...
...
@@ -145,8 +145,8 @@ class SortTest extends TestCase
'route'
=>
'site/index'
,
]);
$this
->
assertEquals
(
'/index.php?r=site
/
index&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
%2F
index&sort=-age%2C-name'
,
$sort
->
createUrl
(
'age'
));
$this
->
assertEquals
(
'/index.php?r=site
%2F
index&sort=name%2Cage'
,
$sort
->
createUrl
(
'name'
));
}
public
function
testLink
()
...
...
@@ -173,6 +173,6 @@ class SortTest extends TestCase
'route'
=>
'site/index'
,
]);
$this
->
assertEquals
(
'<a class="asc" href="/index.php?r=site
/
index&sort=-age%2C-name" data-sort="-age,-name">Age</a>'
,
$sort
->
link
(
'age'
));
$this
->
assertEquals
(
'<a class="asc" href="/index.php?r=site
%2F
index&sort=-age%2C-name" data-sort="-age,-name">Age</a>'
,
$sort
->
link
(
'age'
));
}
}
tests/unit/framework/helpers/SecurityTest.php
View file @
873b2b04
...
...
@@ -10,6 +10,9 @@ namespace yiiunit\framework\helpers;
use
yiiunit\TestCase
;
use
yii\helpers\Security
;
/**
* @group helpers
*/
class
SecurityTest
extends
TestCase
{
public
function
testPasswordHash
()
...
...
tests/unit/framework/helpers/UrlTest.php
View file @
873b2b04
...
...
@@ -9,6 +9,7 @@ use yiiunit\TestCase;
/**
* UrlTest
* @group helpers
*/
class
UrlTest
extends
TestCase
{
...
...
@@ -21,7 +22,7 @@ class UrlTest extends TestCase
'class'
=>
'yii\web\Request'
,
'scriptUrl'
=>
'/base/index.php'
,
'hostInfo'
=>
'http://example.com/'
,
'url'
=>
'/base/index.php&r=site
/
current&id=42'
'url'
=>
'/base/index.php&r=site
%2F
current&id=42'
],
],
],
'\yii\web\Application'
);
...
...
@@ -56,24 +57,24 @@ class UrlTest extends TestCase
$this
->
mockAction
(
'page'
,
'view'
,
null
,
[
'id'
=>
10
]);
// 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
(
'http://example.com/base/index.php?r=page
/
view'
,
Url
::
toRoute
(
''
,
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=page
/
view'
,
Url
::
toRoute
(
''
,
'https'
));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
view'
,
Url
::
toRoute
(
''
));
$this
->
assertEquals
(
'http://example.com/base/index.php?r=page
%2F
view'
,
Url
::
toRoute
(
''
,
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=page
%2F
view'
,
Url
::
toRoute
(
''
,
'https'
));
// 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;
$this
->
assertEquals
(
'/base/index.php?r=page
/
edit'
,
Url
::
toRoute
(
'edit'
));
$this
->
assertEquals
(
'/base/index.php?r=page
/
edit&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
(
'https://example.com/base/index.php?r=page
/
edit&id=20'
,
Url
::
toRoute
([
'edit'
,
'id'
=>
20
],
'https'
));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
edit'
,
Url
::
toRoute
(
'edit'
));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
edit&id=20'
,
Url
::
toRoute
([
'edit'
,
'id'
=>
20
]));
$this
->
assertEquals
(
'http://example.com/base/index.php?r=page
%2F
edit&id=20'
,
Url
::
toRoute
([
'edit'
,
'id'
=>
20
],
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=page
%2F
edit&id=20'
,
Url
::
toRoute
([
'edit'
,
'id'
=>
20
],
'https'
));
// 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.
$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
/user/
view&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
(
'https://example.com/base/index.php?r=stats
/user/
view&id=42'
,
Url
::
toRoute
([
'user/view'
,
'id'
=>
42
],
'https'
));
$this
->
assertEquals
(
'/base/index.php?r=stats
%2Fuser%2F
view'
,
Url
::
toRoute
(
'user/view'
));
$this
->
assertEquals
(
'/base/index.php?r=stats
%2Fuser%2F
view&id=42'
,
Url
::
toRoute
([
'user/view'
,
'id'
=>
42
]));
$this
->
assertEquals
(
'http://example.com/base/index.php?r=stats
%2Fuser%2F
view&id=42'
,
Url
::
toRoute
([
'user/view'
,
'id'
=>
42
],
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=stats
%2Fuser%2F
view&id=42'
,
Url
::
toRoute
([
'user/view'
,
'id'
=>
42
],
'https'
));
// In case there is no controller, an exception should be thrown for relative route
$this
->
removeMockedAction
();
...
...
@@ -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
// pairs are treated as the parameters to be used for URL creation using Url::toRoute.
$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
/
edit'
,
Url
::
to
([
'edit'
]));
$this
->
assertEquals
(
'/base/index.php?r=page
/
view'
,
Url
::
to
([
''
]));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
edit&id=20'
,
Url
::
to
([
'edit'
,
'id'
=>
20
]));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
edit'
,
Url
::
to
([
'edit'
]));
$this
->
assertEquals
(
'/base/index.php?r=page
%2F
view'
,
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
/
edit'
,
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
%2F
edit&id=20'
,
Url
::
to
([
'edit'
,
'id'
=>
20
],
true
));
$this
->
assertEquals
(
'http://example.com/base/index.php?r=page
%2F
edit'
,
Url
::
to
([
'edit'
],
true
));
$this
->
assertEquals
(
'http://example.com/base/index.php?r=page
%2F
view'
,
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
/
edit'
,
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
%2F
edit&id=20'
,
Url
::
to
([
'edit'
,
'id'
=>
20
],
'https'
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=page
%2F
edit'
,
Url
::
to
([
'edit'
],
'https'
));
$this
->
assertEquals
(
'https://example.com/base/index.php?r=page
%2F
view'
,
Url
::
to
([
''
],
'https'
));
// is an empty string: the currently requested URL will be returned;
$this
->
mockAction
(
'page'
,
'view'
,
null
,
[
'id'
=>
10
]);
$this
->
assertEquals
(
'/base/index.php&r=site
/
current&id=42'
,
Url
::
to
(
''
));
$this
->
assertEquals
(
'http://example.com/base/index.php&r=site
/
current&id=42'
,
Url
::
to
(
''
,
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php&r=site
/
current&id=42'
,
Url
::
to
(
''
,
'https'
));
$this
->
assertEquals
(
'/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
''
));
$this
->
assertEquals
(
'http://example.com/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
''
,
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
''
,
'https'
));
// 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
...
...
@@ -122,9 +123,9 @@ class UrlTest extends TestCase
$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
(
'/base/index.php&r=site
/
current&id=42'
,
Url
::
to
(
'@web3'
));
$this
->
assertEquals
(
'http://example.com/base/index.php&r=site
/
current&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
(
'/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
'@web3'
));
$this
->
assertEquals
(
'http://example.com/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
'@web3'
,
true
));
$this
->
assertEquals
(
'https://example.com/base/index.php&r=site
%2F
current&id=42'
,
Url
::
to
(
'@web3'
,
'https'
));
$this
->
assertEquals
(
'/test'
,
Url
::
to
(
'@web4'
));
$this
->
assertEquals
(
'http://example.com/test'
,
Url
::
to
(
'@web4'
,
true
));
...
...
@@ -159,7 +160,7 @@ class UrlTest extends TestCase
public
function
testCanonical
()
{
$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
%2F
view&id=10'
,
Url
::
canonical
());
$this
->
removeMockedAction
();
}
}
tests/unit/framework/web/UrlManagerTest.php
View file @
873b2b04
...
...
@@ -24,9 +24,9 @@ class UrlManagerTest extends TestCase
'cache'
=>
null
,
]);
$url
=
$manager
->
createUrl
([
'post/view'
]);
$this
->
assertEquals
(
'?r=post
/
view'
,
$url
);
$this
->
assertEquals
(
'?r=post
%2F
view'
,
$url
);
$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
%2F
view&id=1&title=sample+post'
,
$url
);
// default setting with '/test/' as base url
$manager
=
new
UrlManager
([
...
...
@@ -34,7 +34,7 @@ class UrlManagerTest extends TestCase
'cache'
=>
null
,
]);
$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
%2F
view&id=1&title=sample+post'
,
$url
);
// pretty URL without rules
$manager
=
new
UrlManager
([
...
...
@@ -123,14 +123,14 @@ class UrlManagerTest extends TestCase
'cache'
=>
null
,
]);
$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
%2F
view&id=1&title=sample+post'
,
$url
);
$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
%2F
view&id=1&title=sample+post'
,
$url
);
$manager
->
hostInfo
=
'https://www.example.com'
;
$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
%2F
view&id=1&title=sample+post'
,
$url
);
}
public
function
testParseRequest
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment