1

I'm using PhpSpec to test application Laravel framework. How can I test Api Restful on file Route and post data like when using PHPUnit.

Example :

$res = $this->call('POST', '/articles', [
        'alias'       => 'This is invalid alias',
        'order'       => 'invalid',
    ],[],[], []);
Anoop LL
  • 1,548
  • 2
  • 21
  • 32

2 Answers2

0

Define route restful

    route::resource('articles', 'ArticleController');

and define controller

 `php artisan make:controller ArticleController`

and finally you can see your route

php artisan route:list
paranoid
  • 6,799
  • 19
  • 49
  • 86
0

You don't. PhpSpec is for unit tests, while what you're trying to write is an integration test.

From the introduction to PhpSpec:

[...] The technique is to first use a tool like phpspec to describe the behaviour of an object you are about to write. Next you write just enough code to meet that specification and finally you refactor this code.

Use other tools for integration tests. PHPUnit is great for this kind of testing (despite the fact it's got "unit" in the name).

Jakub Zalas
  • 35,761
  • 9
  • 93
  • 125