I am dabbling with PHPUnit that comes with the Laravel 5.1. I have create a php file under the tests folder with the name 'UserTest.php'. The content of the file is as follows
<?php
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class UserTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testRegistration()
{
echo $this->post('/user/register', ['password' => 'mypass',
'name' => 'Steve Robinson',
'email' => 'stevey@gmail.com']);
/*->seeJson([
'success' => true,
]);*/
}
In the server side I have the following code:
public function store()
{
$credentials = Input::only('name','email', 'password');
try {
$user = User::create($credentials);
} catch (Exception $e) {
return Response::json(['error' => 'User already exists.'], HttpResponse::HTTP_CONFLICT);
}
$token = JWTAuth::fromUser($user);
return Response::json(compact('token'));
}
Whenever I run the command 'phpunit' . It throws an error saying object of class UserTest cannot be converted into string. Please tell me what am I doing wrong here.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire