如何使用phpspec在Laravel上测试Api Restful

如何使用phpspec在Laravel上测试Api Restful,php,laravel,phpspec,Php,Laravel,Phpspec,我正在使用PhpSpec测试应用程序Laravel框架。 如何在文件路由上测试Api Restful,并在使用PHPUnit时发布数据 例如: $res = $this->call('POST', '/articles', [ 'alias' => 'This is invalid alias', 'order' => 'invalid', ],[],[], []); 定义restful路由 route:

我正在使用PhpSpec测试应用程序Laravel框架。 如何在文件路由上测试Api Restful,并在使用PHPUnit时发布数据

例如:

$res = $this->call('POST', '/articles', [
        'alias'       => 'This is invalid alias',
        'order'       => 'invalid',
    ],[],[], []);
定义restful路由

    route::resource('articles', 'ArticleController');
并定义控制器

 `php artisan make:controller ArticleController`
最后你可以看到你的路线

php artisan route:list
定义restful路由

    route::resource('articles', 'ArticleController');
并定义控制器

 `php artisan make:controller ArticleController`
最后你可以看到你的路线

php artisan route:list

你没有。PhpSpec用于单元测试,而您尝试编写的是集成测试

从:

[…]技术是首先使用phpspec之类的工具来描述您将要编写的对象的行为。接下来,您将编写足够的代码来满足该规范,最后重构此代码


使用其他工具进行集成测试。PHPUnit非常适合这种测试(尽管它的名字中有“unit”。

你没有。PhpSpec用于单元测试,而您尝试编写的是集成测试

从:

[…]技术是首先使用phpspec之类的工具来描述您将要编写的对象的行为。接下来,您将编写足够的代码来满足该规范,最后重构此代码

使用其他工具进行集成测试。PHPUnit非常适合这种测试(尽管它的名字中有“unit”)