2015-03-25 15:15:53 +01:00
|
|
|
<?php
|
2015-03-03 17:18:17 +01:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
namespace Tests\PHPCensor\Controller;
|
2015-03-25 15:15:53 +01:00
|
|
|
|
2016-07-19 20:28:11 +02:00
|
|
|
use PHPCensor\Controller\WebhookController;
|
2015-03-25 15:15:53 +01:00
|
|
|
|
2017-07-24 08:45:52 +02:00
|
|
|
class WebhookControllerTest extends \PHPUnit\Framework\TestCase
|
2015-03-25 15:15:53 +01:00
|
|
|
{
|
|
|
|
public function test_wrong_action_name_return_json_with_error()
|
|
|
|
{
|
|
|
|
$webController = new WebhookController(
|
2018-03-04 09:56:02 +01:00
|
|
|
$this->prophesize('PHPCensor\Config')->reveal(),
|
2018-03-04 11:22:14 +01:00
|
|
|
$this->prophesize('PHPCensor\Http\Request')->reveal(),
|
|
|
|
$this->prophesize('PHPCensor\Http\Response')->reveal()
|
2015-03-25 15:15:53 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$error = $webController->handleAction('test', []);
|
|
|
|
|
2018-03-04 11:22:14 +01:00
|
|
|
self::assertInstanceOf('PHPCensor\Http\Response\JsonResponse', $error);
|
2015-03-25 15:15:53 +01:00
|
|
|
|
|
|
|
$responseData = $error->getData();
|
2018-02-16 10:41:56 +01:00
|
|
|
self::assertEquals(500, $responseData['code']);
|
2015-03-25 15:15:53 +01:00
|
|
|
|
2018-02-16 10:41:56 +01:00
|
|
|
self::assertEquals('failed', $responseData['body']['status']);
|
2015-03-25 15:15:53 +01:00
|
|
|
|
2018-02-16 10:41:56 +01:00
|
|
|
self::assertEquals('application/json', $responseData['headers']['Content-Type']);
|
2015-03-25 15:15:53 +01:00
|
|
|
|
|
|
|
// @todo: we can't text the result is JSON file with
|
2018-02-16 10:41:56 +01:00
|
|
|
// self::assertJson((string) $error);
|
2015-03-25 15:15:53 +01:00
|
|
|
// since the flush method automatically add the header and break the
|
|
|
|
// testing framework.
|
|
|
|
}
|
|
|
|
}
|