Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
219
Merge Requests
219
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
144ab03f
Commit
144ab03f
authored
Oct 02, 2013
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2096135
by dawehner, longwave: Fixed PathProcessorAlias ignore 'alias' => TRUE.
parent
33b448c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
3 deletions
+107
-3
core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
+5
-2
core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
+6
-0
core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
...dules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
+7
-1
core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
...rupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
+89
-0
No files found.
core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php
View file @
144ab03f
...
...
@@ -44,8 +44,11 @@ public function processInbound($path, Request $request) {
* Implements Drupal\Core\PathProcessor\OutboundPathProcessorInterface::processOutbound().
*/
public
function
processOutbound
(
$path
,
&
$options
=
array
(),
Request
$request
=
NULL
)
{
$langcode
=
isset
(
$options
[
'language'
])
?
$options
[
'language'
]
->
id
:
NULL
;
$path
=
$this
->
aliasManager
->
getPathAlias
(
$path
,
$langcode
);
if
(
empty
(
$options
[
'alias'
]))
{
$langcode
=
isset
(
$options
[
'language'
])
?
$options
[
'language'
]
->
id
:
NULL
;
$path
=
$this
->
aliasManager
->
getPathAlias
(
$path
,
$langcode
);
}
return
$path
;
}
}
core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
View file @
144ab03f
...
...
@@ -154,6 +154,12 @@ function testNodeAlias() {
$this
->
assertText
(
$node1
->
label
(),
'Alias works.'
);
$this
->
assertResponse
(
200
);
// Confirm the 'canonical' and 'shortlink' URLs.
$elements
=
$this
->
xpath
(
"//link[contains(@rel, 'canonical') and contains(@href, '"
.
$edit
[
'path[alias]'
]
.
"')]"
);
$this
->
assertTrue
(
!
empty
(
$elements
),
'Page contains canonical link URL.'
);
$elements
=
$this
->
xpath
(
"//link[contains(@rel, 'shortlink') and contains(@href, 'node/"
.
$node1
->
id
()
.
"')]"
);
$this
->
assertTrue
(
!
empty
(
$elements
),
'Page contains shortlink URL.'
);
// Change alias to one containing "exotic" characters.
$previous
=
$edit
[
'path[alias]'
];
$edit
[
'path[alias]'
]
=
"- ._~!$'
\"
()*@[]?&+%#,;=:"
.
// "Special" ASCII characters.
...
...
core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
View file @
144ab03f
...
...
@@ -55,13 +55,19 @@ function testTermAlias() {
'path[alias]'
=>
$this
->
randomName
(),
);
$this
->
drupalPostForm
(
'admin/structure/taxonomy/manage/'
.
$vocabulary
->
id
()
.
'/add'
,
$edit
,
t
(
'Save'
));
$tid
=
db_query
(
"SELECT tid FROM
{
taxonomy_term_data
}
WHERE name = :name"
,
array
(
':name'
=>
$edit
[
'name'
]))
->
fetchField
();
// Confirm that the alias works.
$this
->
drupalGet
(
$edit
[
'path[alias]'
]);
$this
->
assertText
(
$description
,
'Term can be accessed on URL alias.'
);
// Confirm the 'canonical' and 'shortlink' URLs.
$elements
=
$this
->
xpath
(
"//link[contains(@rel, 'canonical') and contains(@href, '"
.
$edit
[
'path[alias]'
]
.
"')]"
);
$this
->
assertTrue
(
!
empty
(
$elements
),
'Term page contains canonical link URL.'
);
$elements
=
$this
->
xpath
(
"//link[contains(@rel, 'shortlink') and contains(@href, 'taxonomy/term/"
.
$tid
.
"')]"
);
$this
->
assertTrue
(
!
empty
(
$elements
),
'Term page contains shortlink URL.'
);
// Change the term's URL alias.
$tid
=
db_query
(
"SELECT tid FROM
{
taxonomy_term_data
}
WHERE name = :name"
,
array
(
':name'
=>
$edit
[
'name'
]))
->
fetchField
();
$edit2
=
array
();
$edit2
[
'path[alias]'
]
=
$this
->
randomName
();
$this
->
drupalPostForm
(
'taxonomy/term/'
.
$tid
.
'/edit'
,
$edit2
,
t
(
'Save'
));
...
...
core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php
0 → 100644
View file @
144ab03f
<?php
/**
* @file
* Contains \Drupal\Tests\Core\PathProcessor\PathProcessorAliasTest.
*/
namespace
Drupal\Tests\Core\PathProcessor
;
use
Drupal\Core\PathProcessor\PathProcessorAlias
;
use
Drupal\Tests\UnitTestCase
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Tests the path alias path processor.
*
* @group Drupal
*
* @see \Drupal\Core\PathProcessor\PathProcessorAlias
*/
class
PathProcessorAliasTest
extends
UnitTestCase
{
/**
* The mocked alias manager.
*
* @var \Drupal\Core\Path\AliasManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected
$aliasManager
;
/**
* The tested path processor.
*
* @var \Drupal\Core\PathProcessor\PathProcessorAlias
*/
protected
$pathProcessor
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Path Processor alias'
),
'description'
=>
t
(
'Tests the path alias path processor.'
),
'group'
=>
t
(
'Path API'
),
);
}
protected
function
setUp
()
{
$this
->
aliasManager
=
$this
->
getMock
(
'Drupal\Core\Path\AliasManagerInterface'
);
$this
->
pathProcessor
=
new
PathProcessorAlias
(
$this
->
aliasManager
);
}
/**
* Tests the processInbound method.
*
* @see \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound
*/
public
function
testProcessInbound
()
{
$this
->
aliasManager
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'getSystemPath'
)
->
will
(
$this
->
returnValueMap
(
array
(
array
(
'urlalias'
,
NULL
,
'internal-url'
),
array
(
'url'
,
NULL
,
'url'
),
)));
$request
=
Request
::
create
(
'/urlalias'
);
$this
->
assertEquals
(
'internal-url'
,
$this
->
pathProcessor
->
processInbound
(
'urlalias'
,
$request
));
$request
=
Request
::
create
(
'/url'
);
$this
->
assertEquals
(
'url'
,
$this
->
pathProcessor
->
processInbound
(
'url'
,
$request
));
}
/**
* Tests the processOutbound method.
*
* @see \Drupal\Core\PathProcessor\PathProcessorAlias::processOutbound
*/
public
function
testProcessOutbound
()
{
$this
->
aliasManager
->
expects
(
$this
->
exactly
(
2
))
->
method
(
'getPathAlias'
)
->
will
(
$this
->
returnValueMap
(
array
(
array
(
'internal-url'
,
NULL
,
'urlalias'
),
array
(
'url'
,
NULL
,
'url'
),
)));
$this
->
assertEquals
(
'urlalias'
,
$this
->
pathProcessor
->
processOutbound
(
'internal-url'
));
$options
=
array
(
'alias'
=>
TRUE
);
$this
->
assertEquals
(
'internal-url'
,
$this
->
pathProcessor
->
processOutbound
(
'internal-url'
,
$options
));
$this
->
assertEquals
(
'url'
,
$this
->
pathProcessor
->
processOutbound
(
'url'
));
}
}
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