Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
index 269ba84..08bb7e1 100644
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -1,108 +1,140 @@
<?php
namespace Nasqueron\Notifications\Tests\Analyzers;
use Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer;
use Nasqueron\Notifications\Tests\TestCase;
class GitHubPayloadAnalyzerTest extends TestCase {
/**
* @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer
*/
private $unknownEventAnalyzer;
/**
* @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer
*/
private $pingAnalyzer;
/**
* @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer
*/
private $pushAnalyzer;
+ /**
+ * @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer
+ */
+ private $pushToMappedRepositoryAnalyzer;
+
/**
* Prepares the tests
*/
public function setUp () {
parent::setUp();
$this->unknownEventAnalyzer = new GitHubPayloadAnalyzer(
"Acme", // Expected without known config file
"quux",
new \stdClass
);
$this->pingAnalyzer = new GitHubPayloadAnalyzer(
"Nasqueron", // Expected with known config file
"ping",
new \stdClass
);
$filename = __DIR__ . "/../../data/payloads/GitHubEvents/push.json";
- $payload = json_decode(file_get_contents($filename));
+ $payloadRawContent = file_get_contents($filename);
+
+ $payload = json_decode($payloadRawContent);
$this->pushAnalyzer = new GitHubPayloadAnalyzer(
"Nasqueron", // Expected with known config
"push",
$payload
);
+
+ $dockerPayload = json_decode($payloadRawContent);
+ $dockerPayload->repository->name = "docker-someapp";
+ $this->pushToMappedRepositoryAnalyzer = new GitHubPayloadAnalyzer(
+ "Nasqueron", // Expected with known config
+ "push",
+ $dockerPayload
+ );
}
///
/// Test constructor
///
/**
* @expectedException InvalidArgumentException
*/
public function testConstructorThrowsAnExceptionWhenPayloadIsInvalid () {
new GitHubPayloadAnalyzer(
"Acme",
"push",
"This is not an object deserialized from JSON but a string."
);
}
///
/// Test getConfigurationFileName
///
public function testGetConfigurationFileNameWhenConfigExists () {
$this->assertSame(
"GitHubPayloadAnalyzer/Nasqueron.json",
$this->pingAnalyzer->getConfigurationFileName()
);
}
public function testGetConfigurationFileNameWhenConfigDoesNotExist () {
$this->assertSame(
"GitHubPayloadAnalyzer/default.json",
$this->unknownEventAnalyzer->getConfigurationFileName()
);
}
///
/// Test getRepository
///
public function testGetRepositoryWhenEventIsAdministrative () {
$this->assertEmpty($this->pingAnalyzer->getRepository());
}
public function testGetRepositoryWhenEventIsRepositoryRelative () {
$this->assertSame("public-repo", $this->pushAnalyzer->getRepository());
}
+ ///
+ /// Test getGroup
+ ///
+
+ public function testGetGroupWhenEventIsAdministrative () {
+ $this->assertSame("orgz", $this->pingAnalyzer->getGroup());
+ }
+
+ public function testGetGroupOnPushToMappedRepository () {
+ $this->assertSame("docker", $this->pushToMappedRepositoryAnalyzer->getGroup());
+
+ }
+
+ public function testGetGroupOnPushToNotMappedRepository () {
+ $this->assertSame("nasqueron", $this->pushAnalyzer->getGroup());
+ }
+
///
/// Test if our fallback is correct when the GitHub event type is unknown
///
- public function testDescriptionContainsTypeWhenEventTypeIsUnknown () {
- $this->assertContains(
- "quux",
- $this->unknownEventAnalyzer->getDescription()
- );
- }
+ public function testDescriptionContainsTypeWhenEventTypeIsUnknown () {
+ $this->assertContains(
+ "quux",
+ $this->unknownEventAnalyzer->getDescription()
+ );
+ }
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 10:30 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2260006
Default Alt Text
(4 KB)

Event Timeline