CakePHP core tests not working on IIS

北城以北 提交于 2020-01-05 10:31:31

问题


I'm following the steps (from http://book.cakephp.org/2.0/en/development/testing.html) to set up Testing on a CakePHP install.

Viewing the core tests is supposed to be as simple as appending /test.php to my application's URL. But when I do that, I get an error page, saying...

Missing Controller

Error: Test.phpController could not be found.

Error: Create the class Test.phpController below in file: my-app\Controller\Test.phpController.php

Obviously, "test.php" is supposed to be a real file, not the name of a controller, so I think either my IIS rewrites might be incorrect, or maybe some setting in test.php itself? I haven't found anything useful elsewhere on the Internet so I'm asking here.

(By the way, my app works pretty well, but I didn't install it from scratch -- a colleague created the app initially, so I can't swear that all the defaults are set as they would be on an out-of-the-box CakePHP installation.)


回答1:


The fix for my problem was twofold. First, rather than appending test.php, I had to append webroot/test.php. Then I had to deactivate "Imported Rule 3" from CakePHP's URL rewrites on IIS7. This rule says:

<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="app/webroot/{R:1}" />

I am not sure why that rewrite rule was included, but it doesn't seem to be necessary, and it prevents test.php from working.



来源:https://stackoverflow.com/questions/16309260/cakephp-core-tests-not-working-on-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!