Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56368951
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
index a6073b6..269ba84 100644
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -1,83 +1,108 @@
<?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;
+
/**
* 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));
+ $this->pushAnalyzer = new GitHubPayloadAnalyzer(
+ "Nasqueron", // Expected with known config
+ "push",
+ $payload
+ );
}
///
/// 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 if our fallback is correct when the GitHub event type is unknown
///
public function testDescriptionContainsTypeWhenEventTypeIsUnknown () {
$this->assertContains(
"quux",
$this->unknownEventAnalyzer->getDescription()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 7, 12:25 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4249851
Default Alt Text
(3 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment