Skip to content

Commit

Permalink
Merge pull request #4046 from thangnnmd/unitTest_BcPlugin_siteRouting
Browse files Browse the repository at this point in the history
BcPlugin::siteRouting
  • Loading branch information
HungDV2022 authored Nov 26, 2024
2 parents aab2513 + 73bc25f commit ae73e10
Show file tree
Hide file tree
Showing 2 changed files with 19 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 @@ -572,6 +572,7 @@ function(RouteBuilder $routes) use($isApi) {
* @return RouteBuilder
* @checked
* @noTodo
* @unitTest
*/
public function siteRouting(RouteBuilder $routes, string $plugin)
{
Expand Down
18 changes: 18 additions & 0 deletions plugins/baser-core/tests/TestCase/BcPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,4 +684,22 @@ public function testContentsRoutingForReverse()
]));
}

/**
* test siteRouting
*/
public function testSiteRouting()
{
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();

Router::reload();
$routes = Router::createRouteBuilder('');
$_SERVER['REQUEST_URI'] = '/s/';
$this->BcPlugin->clearCurrentSite();
$this->BcPlugin->routes($routes);
$result = Router::parseRequest($this->getRequest('/s/bc-blog/blog_contents/index'));
$this->assertEquals('BlogContents', $result['controller']);
}

}

0 comments on commit ae73e10

Please sign in to comment.