diff --git a/tests/unit/Espo/Core/Utils/RouteTest.php b/tests/unit/Espo/Core/Utils/RouteTest.php index 3d2a95dd93..1b286d37c9 100644 --- a/tests/unit/Espo/Core/Utils/RouteTest.php +++ b/tests/unit/Espo/Core/Utils/RouteTest.php @@ -330,4 +330,66 @@ class RouteTest extends \PHPUnit_Framework_TestCase $this->assertEquals($result, $this->reflection->invokeMethod('unify')); } + + public function testUnifyCase4ModuleRoutesWithRewrites() + { + // prepare path + $paths = [ + 'corePath' => $this->filesPath.'/testCase4/application/Espo/Resources/routes.json', + 'modulePath' => $this->filesPath.'/testCase4/application/Espo/Modules/{*}/Resources/routes.json', + 'customPath' => $this->filesPath.'/testCase4/custom/Espo/Custom/Resources/routes.json', + ]; + + $this->reflection->setProperty('paths', $paths); + + $this->objects['metadata'] + ->expects($this->once()) + ->method('getModuleList') + ->will($this->returnValue(array( + 'Crm', + 'Test', + 'TestExt' + ))); + + // prepare expected result + $result = [ + [ + 'route' => '/Activities/:scope/:id/:name', + 'method' => 'get', + 'params' => [ + 'controller' => 'TestExt', + 'action' => 'list', + 'scope' => ':scope', + 'id' => ':id', + 'name' => ':name', + ], + ], + [ + 'route' => '/Activities', + 'method' => 'get', + 'params' => [ + 'controller' => 'TestExt', + 'action' => 'testExtListCalendarEvents' + ], + ], + [ + 'route' => '/Product', + 'method' => 'get', + 'params' => [ + 'controller' => 'Product', + 'action' => 'listProduct' + ], + ], + [ + 'route' => '/Test', + 'method' => 'get', + 'params' => [ + 'controller' => 'Test', + 'action' => 'testAction' + ], + ], + ]; + + $this->assertEquals($result, $this->reflection->invokeMethod('unify')); + } } \ No newline at end of file diff --git a/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Crm/Resources/routes.json b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Crm/Resources/routes.json new file mode 100644 index 0000000000..651b53f557 --- /dev/null +++ b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Crm/Resources/routes.json @@ -0,0 +1,29 @@ +[ + { + "route": "/Activities/:scope/:id/:name", + "method": "get", + "params": { + "controller": "Activities", + "action": "list", + "scope": ":scope", + "id": ":id", + "name": ":name" + } + }, + { + "route": "/Activities", + "method": "get", + "params": { + "controller": "Activities", + "action": "listCalendarEvents" + } + }, + { + "route": "/Product", + "method": "get", + "params": { + "controller": "Product", + "action": "listProduct" + } + } +] diff --git a/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Test/Resources/routes.json b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Test/Resources/routes.json new file mode 100644 index 0000000000..4afcff54a9 --- /dev/null +++ b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/Test/Resources/routes.json @@ -0,0 +1,21 @@ +[ + { + "route": "/Activities/:scope/:id/:name", + "method": "get", + "params": { + "controller": "Test", + "action": "list", + "scope": ":scope", + "id": ":id", + "name": ":name" + } + }, + { + "route": "/Test", + "method": "get", + "params": { + "controller": "Test", + "action": "testAction" + } + } +] diff --git a/tests/unit/testData/Routes/testCase4/application/Espo/Modules/TestExt/Resources/routes.json b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/TestExt/Resources/routes.json new file mode 100644 index 0000000000..7c1a791043 --- /dev/null +++ b/tests/unit/testData/Routes/testCase4/application/Espo/Modules/TestExt/Resources/routes.json @@ -0,0 +1,21 @@ +[ + { + "route": "/Activities/:scope/:id/:name", + "method": "get", + "params": { + "controller": "TestExt", + "action": "list", + "scope": ":scope", + "id": ":id", + "name": ":name" + } + }, + { + "route": "/Activities", + "method": "get", + "params": { + "controller": "TestExt", + "action": "testExtListCalendarEvents" + } + } +]