php-censor/tests/PHPCensor/Controller/WebhookControllerTest.php

34 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2016-07-19 20:28:11 +02:00
namespace Tests\PHPCensor\Controller;
2016-07-19 20:28:11 +02:00
use PHPCensor\Controller\WebhookController;
class WebhookControllerTest extends \PHPUnit\Framework\TestCase
{
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()
);
$error = $webController->handleAction('test', []);
2018-03-04 11:22:14 +01:00
self::assertInstanceOf('PHPCensor\Http\Response\JsonResponse', $error);
$responseData = $error->getData();
2018-02-16 10:41:56 +01:00
self::assertEquals(500, $responseData['code']);
2018-02-16 10:41:56 +01:00
self::assertEquals('failed', $responseData['body']['status']);
2018-02-16 10:41:56 +01:00
self::assertEquals('application/json', $responseData['headers']['Content-Type']);
// @todo: we can't text the result is JSON file with
2018-02-16 10:41:56 +01:00
// self::assertJson((string) $error);
// since the flush method automatically add the header and break the
// testing framework.
}
}