Skip to content

Commit

Permalink
Add unitTest_BcPlugin_contentsRoutingForReverse
Browse files Browse the repository at this point in the history
  • Loading branch information
thangnn committed Nov 22, 2024
1 parent 7541e39 commit 93dd2d7
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 93dd2d7

Please sign in to comment.