无法运行Slim Framework中提供的测试

我正在尝试为我的Android应用程序创建一个简单的休息客户端。 我想以TDD的方式做,但为此,我需要为所有操作(GET,POST等)进行简单的工作配置。 经过一番挣扎,我能够通过获取请求进行测试工作。 不幸的是,邮政路线的情况并不顺利。 在本地服务器(xampp 5.6.3)上测试(netbeans 8.0.2 + phpunit)时,我得到的是404错误。 如果我运行使用Advanced Rest Client Application(chrome扩展)测试的方法,则同样如此。 当我将我的休息文件发送到实时托管时,那么有问题的方法可以正常工作。 </ p>

在搜索了几天之后(在Slim Framework上阅读404错误的所有内容)我决定从一些应该正常工作的东西开始。 超薄框架带有简单的演示应用程序和一些测试。 这里我有另一个错误阻止测试开始:
Fatal错误:在第3行的C:\ xampp \ htdocs \ web \ local \ codeguy-Slim-04958a1 \ tests \ MiddlewareTest.php中找不到类'Slim \ Middleware' / p>

到目前为止,我可以说我的xampp服务器有问题,但我没有更多的想法如何解决这个问题。 所以,如果有人能告诉我设置Netbeans,Xampp,Slim和phpunit的正确方法(我是从IDE运行它(ALT + F6))那么我就可以在此基础上构建我的休息api。</ p>

</ div>

展开原文

原文

I'm trying to make a simple rest client for my android app. I would like to do than in TDD way, but for that I need simple working configuration for all actions (GET, POST, and so on). After some struggling I was able to make test work with get requests. Unfortunately with Post routes things didn't go well. When testing (netbeans 8.0.2 + phpunit) on local server (xampp 5.6.3) all I get is 404 error. Same thing if I run method being tested with Advanced Rest Client Application (chrome extension). When I send my rest files to live hosting then method in question works as it should.

After searching for some days (read about everything with 404 errors on Slim Framework) I decided to start with something which should work right of the box. Slim framework comes with simple demo app and some tests. Here I have another error which prevents start of tests: Fatal error: Class 'Slim\Middleware' not found in C:\xampp\htdocs\web\local\codeguy-Slim-04958a1\tests\MiddlewareTest.php on line 3

As far I can tell I have something wrong with my xampp server but I don't have any more ideas how to fix this. So If somebody could show me correct way to setup Netbeans, Xampp, Slim and phpunit(I'm running it from IDE (ALT + F6)) then I would be able to build my rest api on top of that.

dourui7186
dourui7186 你会加入这个问题:你是如何安装Slim的?你是如何运行PHPUnit的?
5 年多之前 回复

2个回答



我发现我的测试和框架提供的测试有什么问题。 我不知道我必须在Netbeans的Project配置中设置bootstrap.php文件。</ p>
</ div>

展开原文

原文

I've found out what was wrong with my tests and with test provided with framework. I didn't know that I had to set bootstrap.php file in Project configuration of Netbeans.



我刚试过以下内容,也许它可能会建议尝试不同的路线?</ p>

 <  code> git clone https://github.com/codeguy/Slim.git
cd Slim
//编辑composer.json以包含“phpunit / phpunit”:“4.3。*”
curl -sS https:// getcomposer .org / installer | php
php composer.phar install
./vendor/bin/phpunit
</ code> </ pre>

令我惊讶的是,有些测试失败了 - 所以需要深入研究。 但所有课程都被找到了。</ p>

一切都应该有效,因为项目 好像在Travis CI上建立好了。</ p>
</ div>

展开原文

原文

I just tried the following, maybe it might suggest a different route to try?

git clone https://github.com/codeguy/Slim.git
cd Slim
// Edit composer.json to include "phpunit/phpunit": "4.3.*"
curl -sS https://getcomposer.org/installer | php
php composer.phar install
./vendor/bin/phpunit

A few tests failed for me, surprisingly - so that would need digging into. But all classes were found.

Everything should work though, as the project seems to be building OK over on Travis CI.

douxi6903
douxi6903 我不使用Windows,但大多数都会保持不变。 安装Composer就在这里,我希望PHPUnit是一个批处理文件,例如 \供应商\ BIN \ phpunit.bat。 你当然需要安装Git。 如果Windows证明很尴尬,那么你总是可以使用Vagrant在Linux上执行此操作。
5 年多之前 回复
dos8410
dos8410 从我可以看到你使用的命令是用于Linux? 你能为Win 7提供吗?
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问