Skip to content

Commit

Permalink
Merge pull request #4042 from thangnnmd/unitTest_BcPlugin_contentsRou…
Browse files Browse the repository at this point in the history
…tingForReverse

BcPlugin::contentsRoutingForReverse
  • Loading branch information
HungDV2022 authored Nov 25, 2024
2 parents cbbd8bc + 93dd2d7 commit 2aa02b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/baser-core/src/BcPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ public function routes(RouteBuilder $routes): void
* @return RouteBuilder
* @checked
* @noTodo
* @unitTest
*/
public function contentsRoutingForReverse(RouteBuilder $routes, string $plugin)
{
Expand Down
20 changes: 20 additions & 0 deletions plugins/baser-core/tests/TestCase/BcPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,24 @@ public function testRestApi()
$this->assertEquals(0, count($result->pages));
}

/**
* test contentsRoutingForReverse
*/
public function testContentsRoutingForReverse()
{
SiteFactory::make(['id' => '1', 'main_site_id' => null])->persist();
SiteFactory::make(['id' => '2', 'main_site_id' => 1, 'alias' => 's'])->persist();
ContentFactory::make(['plugin' => 'BcBlog', 'type' => 'BlogContent', 'entity_id' => 31, 'url' => '/news/', 'site_id' => 1])->persist();
$this->BcPlugin = new BcPlugin(['name' => 'BcBlog']);
$routes = Router::createRouteBuilder('/');
$this->BcPlugin->routes($routes);
$this->getRequest('/');
$this->assertEquals('/news/', Router::url([
'plugin' => 'BcBlog',
'controller' => 'Blog',
'action' => 'index',
'entityId' => 31
]));
}

}

0 comments on commit 2aa02b9

Please sign in to comment.