Detailed webhook responses.

Fixed docblocks.

Reworked WebhookController to enforce Json responses in ::handleAction.

Check the project type match the webhook.

When creating several builds, do not stop on first error.

Try to create every builds and report 'ok' if at least one succeeds.

CS fix.

Fixed Uses.

Fixed the types accepted by the git webhook.

Added some really basic test.
This commit is contained in:
Adirelle 2015-03-25 15:15:53 +01:00 committed by Tobias van Beek
commit f3c1a98cf1
2 changed files with 252 additions and 151 deletions

View file

@ -0,0 +1,41 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link http://www.phptesting.org/
*/
namespace PHPCI\Tests\Controller;
use PHPCI\Controller\WebhookController;
use Prophecy\PhpUnit\ProphecyTestCase;
class WebhookControllerTest extends ProphecyTestCase
{
public function test_wrong_action_name_return_json_with_error()
{
$webController = new WebhookController(
$this->prophesize('b8\Config')->reveal(),
$this->prophesize('b8\Http\Request')->reveal(),
$this->prophesize('b8\Http\Response')->reveal()
);
$error = $webController->handleAction('test', []);
$this->assertInstanceOf('b8\Http\Response\JsonResponse', $error);
$responseData = $error->getData();
$this->assertEquals(500, $responseData['code']);
$this->assertEquals('failed', $responseData['body']['status']);
$this->assertEquals('application/json', $responseData['headers']['Content-Type']);
// @todo: we can't text the result is JSON file with
// $this->assertJson((string) $error);
// since the flush method automatically add the header and break the
// testing framework.
}
}