Exemple #1
0
 public function testPut(FunctionalTester $I)
 {
     $put = ['id' => 3, 'name' => 'Put', 'description' => 'Put desc'];
     $I->sendPUT('/foo/2/var/3', $put);
     $I->seeResponseCodeIs(200);
     $I->seeResponseEquals(json_encode($put));
 }
Exemple #2
0
 public function testPost(FunctionalTester $I)
 {
     $post = ['name' => 'Post', 'description' => 'PostDesc'];
     $prepend = ['id' => 3];
     $I->sendPOST('/foo/', $post);
     $prepend += $post;
     $I->seeResponseCodeIs(201);
     //TODO
     //$I->seeHttpHeader('Location', '/basic/3');
     $I->seeResponseEquals(json_encode($prepend));
 }
Exemple #3
0
$I->sendPOST('/users', $newUser);
$I->seeHttpHeader('Status', '400 Password is too short');
///////////////////////////////
$I->amGoingTo('post $newUser ' . $foo['username'] . ' with a valid password');
$newUser = ['username' => $foo['username'], 'password' => $foo['password']];
$I->sendPOST('/users', $newUser);
$I->seeHttpHeader('Status', "201 Created with username {$newUser['username']}");
$I->seeHttpHeader('Location');
$foo['uri'] = $I->grabHttpHeader('Location');
///////////////////////////////
$I->amGoingTo('post $newUser with a existent username');
$newUser = ['username' => 'foo', 'password' => $bar['password']];
$I->sendPOST('/users', $newUser);
$I->seeHttpHeader('Status', "409 User {$newUser['username']} already exists");
///////////////////////////////
$I->amGoingTo('post $newUser ' . $foo['username']);
$newUser = ['username' => $bar['username'], 'password' => $bar['password']];
$I->sendPost('/users', $newUser);
$I->seeHttpHeader('Status', "201 Created with username {$newUser['username']}");
$I->seeHttpHeader('Location');
$bar['uri'] = $I->grabHttpHeader('Location');
///////////////////////////////
$I->amGoingTo('request user $foo at ' . $foo['uri']);
$I->sendGet($foo['uri']);
$I->seeResponseCodeIs(200);
$I->seeResponseEquals(json_encode(['username' => $foo['username'], 'uri' => "/users/{$foo['username']}", 'articles' => "/users/{$foo['username']}/articles"]));
///////////////////////////////
$I->amGoingTo('request all users');
$I->sendGet('/users');
$I->seeResponseCodeIs(200);
$I->seeResponseEquals(json_encode([['username' => $foo['username'], 'uri' => "/users/{$foo['username']}", 'articles' => "/users/{$foo['username']}/articles"], ['username' => $bar['username'], 'uri' => "/users/{$bar['username']}", 'articles' => "/users/{$bar['username']}/articles"]]));
Exemple #4
0
 public function testInternalServerError(FunctionalTester $I)
 {
     $I->sendDELETE('/foo/0');
     $I->seeResponseCodeIs(500);
     $I->seeResponseEquals(json_encode(['message' => 'Internal server error', 'code' => 500]));
 }