Page MenuHomeDevCentral

D280.id.diff
No OneTemporary

D280.id.diff

diff --git a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
--- a/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
+++ b/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php
@@ -95,7 +95,7 @@
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
json_decode(Storage::get($fileName)),
- new GitHubPayloadAnalyzerConfiguration()
+ new GitHubPayloadAnalyzerConfiguration($this->project)
);
}
@@ -145,11 +145,7 @@
}
}
- // By default, fallback group is the project name or a specified value.
- if (empty($this->configuration->defaultGroup)) {
- return strtolower($this->project);
- }
- return $this->configuration->defaultGroup;
+ return $this->configuration->getDefaultGroup();
}
///
diff --git a/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php b/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php
--- a/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php
@@ -3,6 +3,22 @@
namespace Nasqueron\Notifications\Analyzers\GitHub;
class GitHubPayloadAnalyzerConfiguration {
+
+ ///
+ /// Private members
+ ///
+
+ /**
+ * The project this configuration is for
+ *
+ * @var string
+ */
+ private $project;
+
+ ///
+ /// Public properties
+ ///
+
/**
* The group for organization only events
*
@@ -23,4 +39,35 @@
* @var RepositoryGroupMapping[]
*/
public $repositoryMapping;
+
+ ///
+ /// Constructor
+ ///
+
+ /**
+ * Initializes a new instance of the GitHubPayloadAnalyzerConfiguration class
+ *
+ * @param string $project The project name this configuration is related to
+ */
+ public function __construct ($project) {
+ $this->project = $project;
+ }
+
+ ///
+ /// Helper methods
+ ///
+
+ /**
+ * Gets the default group
+ *
+ * @return string the default group, as set in the configuration,
+ * or if omitted, the project name as fallback.
+ */
+ public function getDefaultGroup () {
+ if (empty($this->defaultGroup)) {
+ return strtolower($this->project);
+ }
+
+ return $this->defaultGroup;
+ }
}
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php
@@ -24,7 +24,7 @@
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
json_decode(file_get_contents($filename)),
- new GitHubPayloadAnalyzerConfiguration()
+ new GitHubPayloadAnalyzerConfiguration('Nasqueron')
);
parent::setUp();
@@ -44,4 +44,22 @@
);
}
}
+
+ ///
+ /// Tests for getDefaultGroup
+ ///
+
+ public function testGetDefaultGroup () {
+ $this->configuration->defaultGroup = "quux";
+ $this->assertSame("quux", $this->configuration->getDefaultGroup());
+ }
+
+ public function testGetDefaultGroupWhenNotInConfig () {
+ $this->configuration->defaultGroup = "";
+ $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+
+ $this->configuration->defaultGroup = null;
+ $this->assertSame("nasqueron", $this->configuration->getDefaultGroup());
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 14:28 (3 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2259673
Default Alt Text
D280.id.diff (3 KB)

Event Timeline