Skip to content

Commit

Permalink
Merge branch 'master' into 3.next
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 22, 2018
2 parents f116832 + 4feee54 commit 67a181d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
@@ -1,5 +1,5 @@
# Define the line ending behavior of the different file extensions
# Set default behaviour, in case users don't have core.autocrlf set.
# Set default behavior, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf

Expand Down
2 changes: 1 addition & 1 deletion src/Filesystem/File.php
Expand Up @@ -574,7 +574,7 @@ public function folder()
/**
* Copy the File to $dest
*
* @param string $dest Destination for the copy
* @param string $dest Absolute path to copy the file to.
* @param bool $overwrite Overwrite $dest if exists
* @return bool Success
*/
Expand Down
8 changes: 5 additions & 3 deletions src/Routing/Route/EntityRoute.php
Expand Up @@ -41,13 +41,15 @@ class EntityRoute extends Route
*/
public function match(array $url, array $context = [])
{
if (empty($this->_compiledRoute)) {
$this->compile();
}

if (isset($url['_entity'])) {
$entity = $url['_entity'];
$this->_checkEntity($entity);

preg_match_all('@:(\w+)@', $this->template, $matches);

foreach ($matches[1] as $field) {
foreach ($this->keys as $field) {
if (!isset($url[$field]) && isset($entity[$field])) {
$url[$field] = $entity[$field];
}
Expand Down
27 changes: 27 additions & 0 deletions tests/TestCase/Routing/Route/EntityRouteTest.php
Expand Up @@ -78,6 +78,33 @@ public function testMatchEntityObject()
$this->assertEquals('/articles/2/article-slug', $result);
}

/**
* test that routes match their pattern.
*
* @return void
*/
public function testMatchUnderscoreBetweenVar()
{
$entity = new Article([
'category_id' => 2,
'slug' => 'article-slug'
]);

$route = $route = new EntityRoute(
'/articles/:category_id_:slug',
[
'_name' => 'articlesView',
]
);

$result = $route->match([
'_entity' => $entity,
'_name' => 'articlesView'
]);

$this->assertEquals('/articles/2_article-slug', $result);
}

/**
* test that routes match their pattern.
*
Expand Down

0 comments on commit 67a181d

Please sign in to comment.