Hi people , i'm currently working in a project made with slim framework and i want to know if its possible to use the nice api test json that laravel uses , for example something like this
public function testBasicExample()
{
$this->json('POST', '/user', ['name' => 'Sally'])
->seeJson([
'created' => true,
]);
}
i use https://github.com/laracasts/Integrated by jeffrey for the integrated tests , but i saw that the section of the api only works on laravel projects . Any idea?
Unfortunately, testing is Laravel is tightly coupled with the framework.
Go to vendor/laravel/framework/src/illuminate/Foundation/Testing
All the testing stuff is there. If you open TestCase.php you'll see everything that is required for it to run.
I would forget about that and instead create a PSR package that uses PHPUnit do to tests like you want.
Write something decoupled, for the entire world to use. The future is micro-frameworks + decoupled PSR PHP libraries. You're on Slim, so already half way there.
I'm actually doing some research and probably i wll use this package
http://docs.guzzlephp.org/en/latest/
it seems pretty nice but i miss the laravel api so much :(
In the long run, you'll write longer lasting more maintainable code if you focus on using decoupled PSR packages that have the fewest dependencies possible.
If you are coding for a framework, then your code won't be reusable and will break with framework updates. Not fun. Been there, done that.
So, I applaud you in using Slim + packages.
Sometimes we are attracted by the features of heavily coupled code, but that comes with a big price to pay.