Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Nov 18, 2022
1 parent 4622e6c commit 93eaf9a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DefaultLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getModelLink($action, array $params = null)
}

$dirParts = explode('/', $url);
// replace the current action
// replace the current action if it's not an ID
if (!is_numeric(end($dirParts))) {
array_pop($dirParts);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/CmsActionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ public function testGetModelLink()
$link = $action->getModelLink("testAction");
$this->assertEquals('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/doCustomLink?CustomLink=testAction', $link);

// in model admin with just an id
$controller->getRequest()->setUrl('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/');
$link = $action->getModelLink("testAction");
$this->assertEquals('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/doCustomLink?CustomLink=testAction', $link);

// in nested grid
$controller->getRequest()->setUrl('admin/model_admin/MyModel/EditForm/field/MyModel/item/0/ItemEditForm/field/OtherModel/item/0/edit');
$link = $action->getModelLink("testAction");
Expand Down

0 comments on commit 93eaf9a

Please sign in to comment.