Last active
August 9, 2020 08:13
-
-
Save ismail1432/72f9cb4a69e5ecbab1fc74423fa2e748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PostContentControllerTest extends WebTestCase | |
/** | |
* @dataProvider methodProvider | |
*/ | |
public function testANoPostRequestShouldReturnA405(string $method) | |
{ | |
$client = static::createClient(); | |
$client->request($method, '/contents'); | |
self::assertEquals(405, $client->getResponse()->getStatusCode()); | |
} | |
public function testAPostRequestWithoutAMessageInBodyShouldReturnA400() | |
{ | |
$client = static::createClient(); | |
$client->request('POST', '/contents'); | |
self::assertEquals(400, $client->getResponse()->getStatusCode()); | |
} | |
public function testAPostRequestWithAMessageInBodyShouldReturnA201() | |
{ | |
$request = new Request([],[],[],[],[],[], json_encode(['message' => 'Hello World'])); | |
$notifier = new class implements NotifierInterface { | |
public function send(Notification $notification, Recipient ...$recipients): void | |
{ | |
} | |
}; | |
$controller = new PostContentController(); | |
$response = $controller->__invoke($notifier, $request); | |
self::assertEquals(201, $response->getStatusCode()); | |
} | |
public function methodProvider() | |
{ | |
return [ | |
['GET'], | |
['PUT'], | |
['DELETE'], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment