Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/Analyzers/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHubPayloadAnalyzerTest.php
index c536a8f..b6f2b61 100644
--- a/tests/Analyzers/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHubPayloadAnalyzerTest.php
@@ -1,76 +1,76 @@
<?php
namespace Nasqueron\Notifications\Tests\Analyzers;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Nasqueron\Notifications\Analyzers\GitHubPayloadAnalyzer;
use Nasqueron\Notifications\Analyzers\GitHubPayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Tests\TestCase;
class GitHubPayloadAnalyzerConfigurationTest extends TestCase {
/**
* Configuration
*
* @var Nasqueron\Notifications\Analyzers\GitHubPayloadAnalyzerConfiguration
*/
protected $configuration;
/**
* Prepares the test
*/
public function setUp () {
- $filename = __DIR__ . '/../data/GitHubPayloadAnalyzer-Nasqueron.json';
+ $filename = __DIR__ . '/../data/GitHubPayloadAnalyzer/Nasqueron.json';
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
json_decode(file_get_contents($filename)),
new GitHubPayloadAnalyzerConfiguration()
);
}
/**
* Determines the JSON object is well parsed
*/
public function testProperties () {
$this->assertEquals("orgz", $this->configuration->administrativeGroup);
$this->assertEquals("nasqueron", $this->configuration->defaultGroup);
foreach ($this->configuration->repositoryMapping as $item) {
$this->assertInstanceOf(
'Nasqueron\Notifications\Analyzers\RepositoryGroupMapping',
$item
);
}
}
public function testGetCommitTitle () {
$this->assertEquals("", GitHubPayloadAnalyzer::getCommitTitle(""));
$this->assertEquals("Lorem ipsum dolor", GitHubPayloadAnalyzer::getCommitTitle("Lorem ipsum dolor"));
$longCommitMessages = [
"I was born in a water moon. Some people, especially its inhabitants, called it a planet, but as it was only a little over two hundred kilometres in diameter, 'moon' seems the more accurate term. The moon was made entirely of water, by which I mean it was a globe that not only had no land, but no rock either, a sphere with no solid core at all, just liquid water, all the way down to the very centre of the globe.",
"I was born in a water moon. Some people, especially its inhabitants, called it a planet, but as it was only a little over two hundred kilometres in diameter, 'moon' seems the more accurate term. The moon was made entirely of water, by which I mean it was a globe that not only had no land, but no rock either, a sphere with no solid core at all, just liquid water, all the way down to the very centre of the globe.\n\nIf it had been much bigger the moon would have had a core of ice, for water, though supposedly incompressible, is not entirely so, and will change under extremes of pressure to become ice. (If you are used to living on a planet where ice floats on the surface of water, this seems odd and even wrong, but nevertheless it is the case.) The moon was not quite of a size for an ice core to form, and therefore one could, if one was sufficiently hardy, and adequately proof against the water pressure, make one's way down, through the increasing weight of water above, to the very centre of the moon.",
];
$shortCommitTitle = "I was born in a water moon. Some people, especially its inhabitants, ca…";
foreach ($longCommitMessages as $longCommitMessage) {
$this->assertEquals(
$shortCommitTitle,
GitHubPayloadAnalyzer::getCommitTitle($longCommitMessage)
);
}
}
public function testGetRepositoryAndBranch () {
$this->assertEquals("", GitHubPayloadAnalyzer::getRepositoryAndBranch("", "master"));
$this->assertEquals("", GitHubPayloadAnalyzer::getRepositoryAndBranch("", "foo"));
$this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "master"));
$this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/master"));
$this->assertEquals("quux", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", ""));
$this->assertEquals("quux (branch foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/foo"));
$this->assertEquals("quux (branch feature/foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "refs/heads/feature/foo"));
$this->assertEquals("quux (branch feature/foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "feature/foo"));
$this->assertEquals("quux (branch foo)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "foo"));
$this->assertEquals("quux (branch 0)", GitHubPayloadAnalyzer::getRepositoryAndBranch("quux", "0"));
}
}
diff --git a/tests/Http/Controllers/GitHubGateControllerTest.php b/tests/Http/Controllers/GitHubGateControllerTest.php
index d13b5a7..b41710c 100644
--- a/tests/Http/Controllers/GitHubGateControllerTest.php
+++ b/tests/Http/Controllers/GitHubGateControllerTest.php
@@ -1,46 +1,46 @@
<?php
namespace Nasqueron\Notifications\Tests\Http\Controllers;
use Nasqueron\Notifications\Tests\TestCase;
class GitHubGateControllerTest extends TestCase {
public function setUp () {
parent::setUp();
$this->disableEvents();
}
/**
* GitHub gate works.
*
* @return void
*/
public function testGet () {
$this->visit('/gate/GitHub')
->see('POST');
}
/**
* Tests a GitHub gate payload.
*/
public function testPost () {
- $payload = file_get_contents(__DIR__ . '/../../data/GitHubPingPayload.json');
+ $payload = file_get_contents(__DIR__ . '/../../data/payloads/GitHubPingPayload.json');
$this->sendPayload(
'/gate/GitHub/Quux', // A gate not existing in data/credentials.json
$payload,
'POST',
[
'X-Github-Event' => 'ping',
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c'
]
)
->seeJson([
'gate' => 'GitHub',
'door' => 'Quux',
'actions' => []
]);
$this->assertResponseOk();
}
}
diff --git a/tests/Http/PayloadFullTest.php b/tests/Http/PayloadFullTest.php
index 4d6b093..0af6ff4 100644
--- a/tests/Http/PayloadFullTest.php
+++ b/tests/Http/PayloadFullTest.php
@@ -1,110 +1,110 @@
<?php
namespace Nasqueron\Notifications\Tests;
use Keruald\Broker\BlackholeBroker;
use Nasqueron\Notifications\Features;
class PayloadFullTest extends TestCase {
public function setUp () {
parent::setUp();
$this->disableBroker();
}
/**
* Sends a GitHub ping payload to the application, with a valid signature
*/
protected function sendValidTestPayload () {
return $this->sendTestPayload('sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc');
}
/**
* Sends a GitHub ping payload to the application, with a valid signature
*/
protected function sendInvalidTestPayload () {
return $this->sendTestPayload('sha1=somethingwrong');
}
protected function sendTestPayload ($signature) {
- $payload = file_get_contents(__DIR__ . '/../data/GitHubPingPayload.json');
+ $payload = file_get_contents(__DIR__ . '/../data/payloads/GitHubPingPayload.json');
$this->sendPayload(
'/gate/GitHub/Acme', // A gate existing in data/credentials.json
$payload,
'POST',
[
'X-Github-Event' => 'ping',
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c',
'X-Hub-Signature' => $signature,
]
);
return $this;
}
/**
* Tests a GitHub gate payload.
*/
public function testPost () {
$this->sendValidTestPayload()->seeJson([
'gate' => 'GitHub',
'door' => 'Acme',
'action' => 'AMQPAction'
]);
$this->assertResponseOk();
}
/**
* Same than testPost, but without actions report.
*/
public function testPostWithoutActionsReport () {
Features::disable("ActionsReport");
$this->sendValidTestPayload();
$this->assertEmpty($this->response->getContent());
$this->assertResponseOk();
// Let's throw an Exception at broker level.
// Without ActionsReport, the client must always receive a 200 OK.
$this->app->instance('broker', function ($app) {
// A non omnipotent instance, so it doesn't mock connect().
return new BlackholeBroker;
});
$this->sendValidTestPayload();
$this->assertEmpty($this->response->getContent());
$this->assertResponseOk();
}
/**
* Tests a GitHub gate payload.
*/
public function testInvalidSignature () {
$this->sendInvalidTestPayload()
->assertResponseStatus(403);
}
public function testBrokerIssue () {
$this->mockNotOperationalBroker();
- $payload = file_get_contents(__DIR__ . '/../data/GitHubPingPayload.json');
+ $payload = file_get_contents(__DIR__ . '/../data/payloads/GitHubPingPayload.json');
$this->sendPayload(
'/gate/GitHub/Acme', // A gate existing in data/credentials.json
$payload,
'POST',
[
'X-Github-Event' => 'ping',
'X-Github-Delivery' => 'e5dd9fc7-17ac-11e5-9427-73dad6b9b17c',
'X-Hub-Signature' => 'sha1=25f6cbd17ea4c6c69958b95fb88c879de4b66dcc',
]
)->seeJson([
'gate' => 'GitHub',
'door' => 'Acme',
'action' => 'AMQPAction',
'type' => 'RuntimeException',
]);
$this->assertResponseStatus(503);
}
}
diff --git a/tests/data/GitHubPayloadAnalyzer-Nasqueron.json b/tests/data/GitHubPayloadAnalyzer/Nasqueron.json
similarity index 100%
rename from tests/data/GitHubPayloadAnalyzer-Nasqueron.json
rename to tests/data/GitHubPayloadAnalyzer/Nasqueron.json
diff --git a/tests/data/GitHubPingPayload.json b/tests/data/payloads/GitHubPingPayload.json
similarity index 100%
rename from tests/data/GitHubPingPayload.json
rename to tests/data/payloads/GitHubPingPayload.json

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 18, 17:58 (8 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2991194
Default Alt Text
(10 KB)

Event Timeline