Page MenuHomeDevCentral

No OneTemporary

diff --git a/composer.json b/composer.json
index 4a12cb2..96a33ce 100644
--- a/composer.json
+++ b/composer.json
@@ -1,67 +1,67 @@
{
"name": "nasqueron/notifications",
"description": "Nasqueron notifications center",
"keywords": [
"nasqueron",
"activemq",
"AMQP",
"notifications"
],
"license": "BSD-2-Clause",
"type": "project",
"require": {
"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": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpmd/phpmd" : "@stable",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"squizlabs/php_codesniffer": "2.*",
"symfony/css-selector": "~3.0",
"symfony/dom-crawler": "~3.0"
},
"autoload": {
"psr-4": {
"Nasqueron\\Notifications\\": "app/",
"Nasqueron\\Notifications\\Tests\\": "tests/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"phpmd": [
"vendor/bin/phpmd app/ xml ruleset.xml"
],
"test": [
"phpunit --no-coverage"
]
},
"config": {
"preferred-install": "dist"
}
}
diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php
new file mode 100644
index 0000000..141972c
--- /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
index 29a882e..d4e12c4 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -1,92 +1,102 @@
<?php
namespace Nasqueron\Notifications\Tests;
use Illuminate\Contracts\Console\Kernel;
+use Keruald\Broker\BlackholeBroker;
use Mockery;
class TestCase extends \Illuminate\Foundation\Testing\TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
///
/// Helpers to mock application services
///
/**
* Mocks the events dispatcher
*/
public function disableEvents () {
// Disables events
// This allows to test a single component and not all the application
$mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');
$mock->shouldReceive('fire');
$mock->shouldReceive('listen');
$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
///
/**
* Visits the given URI with a JSON request.
*
* @param string $uri
* @param mixed $data
* @param string $method
* @param array $headers
* @return $this
*/
public function sendJsonPayload ($uri, $data, $method = 'POST', array $headers = []) {
$content = json_encode($data);
$headers = array_merge([
'CONTENT_TYPE' => 'application/json',
'Accept' => 'application/json',
], $headers);
return $this->sendPayload($uri, $content, $method, $headers);
}
/**
* Visits the given URI with a raw request.
*
* @param string $uri
* @param string $content
* @param string $method
* @param array $headers
* @return $this
*/
public function sendPayload ($uri, $content, $method = 'POST', array $headers = []) {
$headers = array_merge([
'CONTENT_LENGTH' => mb_strlen($content, '8bit'),
], $headers);
$this->call(
$method, $uri, [], [], [], $this->transformHeadersToServerVars($headers), $content
);
return $this;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Sep 15, 06:04 (14 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2983803
Default Alt Text
(5 KB)

Event Timeline