diff --git a/composer.json b/composer.json --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": ">=5.6.0", "laravel/framework": "5.2.*", "keruald/github": ">=0.2.0", - "keruald/broker": ">=0.1.0", + "keruald/broker": ">=0.2.0", "netresearch/jsonmapper": "~0.1.0" }, "require-dev": { diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php new file mode 100644 --- /dev/null +++ b/tests/Http/PayloadFullTest.php @@ -0,0 +1,35 @@ +<?php + +namespace Nasqueron\Notifications\Tests; + +class PayloadFullTest extends TestCase { + + public function setUp () { + parent::setUp(); + + $this->disableBroker(); + } + + /** + * Tests a GitHub gate payload. + */ + public function testPost () { + $payload = file_get_contents(__DIR__ . '/../data/GitHubPingPayload.json'); + $this->sendPayload( + '/gate/GitHub/Quux', + $payload, + 'POST', + [ + 'X-Github-Event' => 'ping', + 'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c' + ] + ) + ->seeJson([ + 'gate' => 'GitHub', + 'door' => 'Quux', + 'action' => 'AMQPAction' + ]); + + $this->assertResponseOk(); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,6 +3,7 @@ namespace Nasqueron\Notifications\Tests; use Illuminate\Contracts\Console\Kernel; +use Keruald\Broker\BlackholeBroker; use Mockery; @@ -47,6 +48,15 @@ $this->app->instance('events', $mock); } + /** + * Mocks the broker + */ + public function disableBroker () { + $broker = new BlackholeBroker(); + $broker->acceptAllMethodCalls(); // allows to be used as a mock + $this->app->instance('broker', $broker); + } + /// /// Helpers to post data to gates ///