ozee31 / cakephp-cors

A CakePHP (3.3+) plugin for activate cors domain in your application
MIT License
43 stars 31 forks source link

Problem when running IntegrationTestCases #18

Closed Zuluru closed 5 years ago

Zuluru commented 5 years ago

I am loading the plugin as normal in my Application's bootstrap function:

$this->addPlugin('Cors', ['bootstrap' => true, 'routes' => false]);

Regular page loads work just fine. But when I'm running unit tests, IntegrationTestCase::_sendRequest calls

$url = $dispatcher->resolveUrl($url);

and then

$response = $dispatcher->execute($request);

Both of these calls apparently result in BasePlugin::bootstrap being called. So the CORS plugin's bootstrap.php is called twice. And the second time through, it overwrites the baseExceptionRenderer in the config with the value it put into exceptionRenderer the first time through. Which means that the AppExceptionRenderer class tries to extend itself, with predictable failure.

Is this some problem exclusive to my setup? Or have others simply not experienced unhandled errors during unit testing with this plugin in place?

Wonder if the bootstrap.php being called twice will also mean the middleware is registered in the queue twice, which might cause other problems?

Zuluru commented 5 years ago

Anyone have any thoughts on this?

Zuluru commented 5 years ago

Looks like #20 is a different symptom of the same problem.

ozee31 commented 5 years ago

Pull request merged, thank you @Zuluru