Page MenuHomeDevCentral

D629.id1570.diff
No OneTemporary

D629.id1570.diff

diff --git a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php b/app/Analyzers/BasePayloadAnalyzer.php
copy from app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
copy to app/Analyzers/BasePayloadAnalyzer.php
--- a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
+++ b/app/Analyzers/BasePayloadAnalyzer.php
@@ -1,13 +1,14 @@
<?php
-namespace Nasqueron\Notifications\Analyzers\Jenkins;
+namespace Nasqueron\Notifications\Analyzers;
use Config;
use Storage;
+use BadMethodCallException;
use InvalidArgumentException;
-class JenkinsPayloadAnalyzer {
+abstract class BasePayloadAnalyzer {
///
/// Private members
@@ -17,19 +18,19 @@
* The project name, used to load specific configuration and offer defaults
* @var string
*/
- private $project;
+ protected $project;
/**
* The request content, as a structured data
* @var stdClass
*/
- private $payload;
+ protected $payload;
/**
* The configuration for the payload analyzer
- * @var Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration;
+ * @var Nasqueron\Notifications\Analyzers\BasePayloadAnalyzerConfiguration;
*/
- private $configuration;
+ protected $configuration;
///
/// Constructor
@@ -67,7 +68,8 @@
* @return string
*/
public function getConfigurationFileName () {
- $dir = Config::get('services.jenkins.analyzer.configDir');
+ $dir = Config::get('services.' . strtolower(static::SERVICE_NAME) . '.analyzer.configDir');
+
$filename = $dir . '/' . $this->project . '.json';
if (!Storage::has($filename)) {
@@ -77,12 +79,43 @@
return $filename;
}
+ /**
+ * Gets full qualified class name for configuration.
+ *
+ * @return string
+ */
+ private function getCandidateConfigurationClassName() {
+ $namespace = 'Nasqueron\Notifications\Analyzers\\' . static::SERVICE_NAME;
+ return $namespace . "\\" . static::SERVICE_NAME . 'PayloadAnalyzerConfiguration';
+ }
+
+ /**
+ * Gets full qualified class name for configuration if existing,
+ * or PayloadAnalyzerConfiguration class if not.
+ *
+ * @return string The configuration class to use
+ */
+ private function getConfigurationClassName () {
+ $class = $this->getCandidateConfigurationClassName();
+
+ if (class_exists($class)) {
+ return $class;
+ }
+
+ return PayloadAnalyzerConfiguration::class;
+ }
+
+ /**
+ * Loads configuration for the analyzer
+ */
public function loadConfiguration () {
$fileName = $this->getConfigurationFileName();
+ $class = $this->getConfigurationClassName();
+
$mapper = new \JsonMapper();
$this->configuration = $mapper->map(
json_decode(Storage::get($fileName)),
- new JenkinsPayloadAnalyzerConfiguration($this->project)
+ new $class($this->project)
);
}
@@ -91,12 +124,22 @@
///
/**
- * Gets the name of the repository.
+ * Gets the name of the item.
*
* @var string
*/
- public function getJobName () {
- return $this->payload->name;
+ public function getItemName () {
+ throw new BadMethodCallException("The getItemName method must be implemented in the analyzer class if used.");
+ }
+
+ /**
+ * Determines if the event isn't related to a specific item,
+ * but to the general service.
+ *
+ * @return bool
+ */
+ public function isAdministrativeEvent () {
+ return false;
}
/**
@@ -105,10 +148,16 @@
* @return string The group, central part of the routing key
*/
public function getGroup () {
+ // Some events are organization-level only and can't be mapped
+ // to projects.
+ if ($this->isAdministrativeEvent()) {
+ return $this->configuration->administrativeGroup;
+ }
+
// If the payload is about some repository matching a table of
// symbols, we need to sort it to the right group.
- $item = $this->getJobName();
- foreach ($this->configuration->groupsMapping as $mapping) {
+ $item = $this->getItemName();
+ foreach ($this->configuration->map as $mapping) {
if ($mapping->doesItemBelong($item)) {
return $mapping->group;
}
@@ -117,57 +166,4 @@
return $this->configuration->getDefaultGroup();
}
- ///
- /// Notify only on failure helper methods
- ///
-
- /**
- * Tries to get build status.
- *
- * @param out string $status
- * @return bool indicates if the build status is defined in the payload
- */
- private function tryGetBuildStatus (&$status) {
- if (!isset($this->payload->build->status)) {
- return false;
- }
-
- $status = $this->payload->build->status;
- return true;
- }
-
- /**
- * @return bool
- */
- public function shouldNotifyOnlyOnFailure () {
- return in_array(
- $this->getJobName(),
- $this->configuration->notifyOnlyOnFailure
- );
- }
-
- /**
- * Determines if the build status is a failure.
- *
- * @return bool
- */
- public function isFailure () {
- if (!$this->tryGetBuildStatus($status)) {
- return false;
- }
-
- return $status === "FAILURE"
- || $status === "ABORTED"
- || $status === "UNSTABLE";
- }
-
- /**
- * Indicates if we should handle this payload to trigger a notification.
- *
- * @return bool if false, this payload is to be ignored for notifications
- */
- public function shouldNotify () {
- return $this->isFailure() || !$this->shouldNotifyOnlyOnFailure();
- }
-
}
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
@@ -2,43 +2,28 @@
namespace Nasqueron\Notifications\Analyzers\GitHub;
+use Nasqueron\Notifications\Analyzers\BasePayloadAnalyzer;
use Nasqueron\Notifications\Analyzers\GitHub\Events\Event;
use Nasqueron\Notifications\Analyzers\GitHub\Events\UnknownEvent;
-use Config;
-use Storage;
+class GitHubPayloadAnalyzer extends BasePayloadAnalyzer {
-class GitHubPayloadAnalyzer {
+ /**
+ * The name of the service, used to get specific classes and config
+ */
+ const SERVICE_NAME = "GitHub";
///
/// Private members
///
/**
- * The project name, used to load specific configuration and offer defaults
- * @var string
- */
- private $project;
-
- /**
* The GitHub event triggering this request
* @var string
*/
private $event;
/**
- * The request content, as a structured data
- * @var stdClass
- */
- private $payload;
-
- /**
- * The configuration for the payload analyzer
- * @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzerConfiguration;
- */
- private $configuration;
-
- /**
* The payload analyzer event
*
* @var Nasqueron\Notifications\Analyzers\GitHub\Events\Event;
@@ -57,15 +42,9 @@
* @param stdClass $payload
*/
public function __construct($project, $event, $payload) {
- if (!is_object($payload)) {
- throw new \InvalidArgumentException("Payload must be an object.");
- }
+ parent::__construct($project, $payload);
- $this->project = $project;
$this->event = $event;
- $this->payload = $payload;
-
- $this->loadConfiguration($project);
try {
$this->analyzerEvent = Event::forPayload($event, $payload);
@@ -75,49 +54,15 @@
}
///
- /// Configuration
- ///
-
- /**
- * The default name of the configuration file
- */
- const CONFIG_DEFAULT_FILE = 'default.json';
-
- /**
- * Gets the full path to the configuration file.
- *
- * @return string
- */
- public function getConfigurationFileName () {
- $dir = Config::get('services.github.analyzer.configDir');
- $filename = $dir . '/' . $this->project . '.json';
-
- if (!Storage::has($filename)) {
- return $dir . '/' . static::CONFIG_DEFAULT_FILE;
- }
-
- return $filename;
- }
-
- public function loadConfiguration () {
- $fileName = $this->getConfigurationFileName();
- $mapper = new \JsonMapper();
- $this->configuration = $mapper->map(
- json_decode(Storage::get($fileName)),
- new GitHubPayloadAnalyzerConfiguration($this->project)
- );
- }
-
- ///
/// Properties
///
/**
- * Gets the name of the repository.
+ * Gets the name of the item, ie here of the name of the repository.
*
* @var string
*/
- public function getRepository () {
+ public function getItemName () {
if ($this->isAdministrativeEvent()) {
return '';
}
@@ -142,30 +87,6 @@
return in_array($this->event, $administrativeEvents);
}
- /**
- * Gets the group for a specific payload.
- *
- * @return string The group, central part of the routing key
- */
- public function getGroup () {
- // Some events are organization-level only and can't be mapped to an
- // existing repository.
- if ($this->isAdministrativeEvent()) {
- return $this->configuration->administrativeGroup;
- }
-
- // If the payload is about some repository matching a table of
- // symbols, we need to sort it to the right group.
- $repository = $this->getRepository();
- foreach ($this->configuration->repositoryMapping as $mapping) {
- if ($mapping->doesItemBelong($repository)) {
- return $mapping->group;
- }
- }
-
- return $this->configuration->getDefaultGroup();
- }
-
///
/// Description of the payload
///
diff --git a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
--- a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
+++ b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php
@@ -2,121 +2,33 @@
namespace Nasqueron\Notifications\Analyzers\Jenkins;
+use Nasqueron\Notifications\Analyzers\BasePayloadAnalyzer;
+
use Config;
use Storage;
use InvalidArgumentException;
-class JenkinsPayloadAnalyzer {
-
- ///
- /// Private members
- ///
-
- /**
- * The project name, used to load specific configuration and offer defaults
- * @var string
- */
- private $project;
-
- /**
- * The request content, as a structured data
- * @var stdClass
- */
- private $payload;
-
- /**
- * The configuration for the payload analyzer
- * @var Nasqueron\Notifications\Analyzers\Jenkins\JenkinsPayloadAnalyzerConfiguration;
- */
- private $configuration;
-
- ///
- /// Constructor
- ///
-
- /**
- * Creates a new JenkinsPayloadAnalyzer instance.
- *
- * @param string $project
- * @param stdClass $payload
- */
- public function __construct($project, $payload) {
- if (!is_object($payload)) {
- throw new InvalidArgumentException("Payload must be an object.");
- }
-
- $this->project = $project;
- $this->payload = $payload;
-
- $this->loadConfiguration($project);
- }
-
- ///
- /// Configuration
- ///
-
- /**
- * The default name of the configuration file
- */
- const CONFIG_DEFAULT_FILE = 'default.json';
+class JenkinsPayloadAnalyzer extends BasePayloadAnalyzer {
/**
- * Gets the full path to the configuration file.
- *
- * @return string
+ * The name of the service, used to get specific classes and config
*/
- public function getConfigurationFileName () {
- $dir = Config::get('services.jenkins.analyzer.configDir');
- $filename = $dir . '/' . $this->project . '.json';
-
- if (!Storage::has($filename)) {
- return $dir . '/' . static::CONFIG_DEFAULT_FILE;
- }
-
- return $filename;
- }
-
- public function loadConfiguration () {
- $fileName = $this->getConfigurationFileName();
- $mapper = new \JsonMapper();
- $this->configuration = $mapper->map(
- json_decode(Storage::get($fileName)),
- new JenkinsPayloadAnalyzerConfiguration($this->project)
- );
- }
+ const SERVICE_NAME = "Jenkins";
///
- /// Properties
+ /// Payload custom properties
///
/**
- * Gets the name of the repository.
+ * Gets the name of the item, ie here of the job.
*
* @var string
*/
- public function getJobName () {
+ public function getItemName () {
return $this->payload->name;
}
- /**
- * Gets the group for a specific payload.
- *
- * @return string The group, central part of the routing key
- */
- public function getGroup () {
- // If the payload is about some repository matching a table of
- // symbols, we need to sort it to the right group.
- $item = $this->getJobName();
- foreach ($this->configuration->groupsMapping as $mapping) {
- if ($mapping->doesItemBelong($item)) {
- return $mapping->group;
- }
- }
-
- return $this->configuration->getDefaultGroup();
- }
-
///
/// Notify only on failure helper methods
///
@@ -141,7 +53,7 @@
*/
public function shouldNotifyOnlyOnFailure () {
return in_array(
- $this->getJobName(),
+ $this->getItemName(),
$this->configuration->notifyOnlyOnFailure
);
}
diff --git a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfiguration.php b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfiguration.php
--- a/app/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfiguration.php
@@ -2,71 +2,17 @@
namespace Nasqueron\Notifications\Analyzers\Jenkins;
-class JenkinsPayloadAnalyzerConfiguration {
+use Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration;
- ///
- /// Private members
- ///
-
- /**
- * The project this configuration is for
- *
- * @var string
- */
- private $project;
+class JenkinsPayloadAnalyzerConfiguration extends PayloadAnalyzerConfiguration {
///
/// Public properties
///
/**
- * The default group to fallback for any event not mapped in another group
- *
- * @var string
- */
- public $defaultGroup;
-
- /**
- * An array of RepositoryGroupMapping objects to match jobs & groups
- *
- * @var \Nasqueron\Notifications\Analyzers\ItemGroupMapping[]
- */
- public $groupsMapping;
-
- /**
* @var array
*/
public $notifyOnlyOnFailure;
- ///
- /// 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/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php b/app/Analyzers/PayloadAnalyzerConfiguration.php
rename from app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php
rename to app/Analyzers/PayloadAnalyzerConfiguration.php
--- a/app/Analyzers/GitHub/GitHubPayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/PayloadAnalyzerConfiguration.php
@@ -1,8 +1,8 @@
<?php
-namespace Nasqueron\Notifications\Analyzers\GitHub;
+namespace Nasqueron\Notifications\Analyzers;
-class GitHubPayloadAnalyzerConfiguration {
+class PayloadAnalyzerConfiguration {
///
/// Private members
@@ -13,7 +13,7 @@
*
* @var string
*/
- private $project;
+ protected $project;
///
/// Public properties
@@ -38,14 +38,14 @@
*
* @var \Nasqueron\Notifications\Analyzers\ItemGroupMapping[]
*/
- public $repositoryMapping;
+ public $map;
///
/// Constructor
///
/**
- * Initializes a new instance of the GitHubPayloadAnalyzerConfiguration class
+ * Initializes a new instance of the BasePayloadAnalyzerConfiguration class
*
* @param string $project The project name this configuration is related to
*/
@@ -70,4 +70,5 @@
return $this->defaultGroup;
}
+
}
diff --git a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
--- a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
+++ b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzer.php
@@ -2,35 +2,27 @@
namespace Nasqueron\Notifications\Analyzers\Phabricator;
+use Nasqueron\Notifications\Analyzers\BasePayloadAnalyzer;
+
use Nasqueron\Notifications\Phabricator\PhabricatorStory;
-use Config;
-use Storage;
+class PhabricatorPayloadAnalyzer extends BasePayloadAnalyzer {
-class PhabricatorPayloadAnalyzer {
+ /**
+ * The name of the service, used to get specific classes and config
+ */
+ const SERVICE_NAME = "Phabricator";
///
/// Private members
///
/**
- * The project name, used to load specific configuration and offer defaults
- * @var string
- */
- private $project;
-
- /**
* The story
* @var PhabricatorStory
*/
private $story;
- /**
- * The configuration for the payload analyzer
- * @var PhabricatorPayloadAnalyzerConfiguration;
- */
- private $configuration;
-
///
/// Constructor
///
@@ -49,71 +41,18 @@
}
///
- /// Configuration
- ///
-
- /**
- * The default name of the configuration file
- */
- const CONFIG_DEFAULT_FILE = 'default.json';
-
- /**
- * Gets the full path to the configuration file.
- *
- * @return string
- */
- public function getConfigurationFileName () {
- $dir = Config::get('services.phabricator.analyzer.configDir');
- $filename = $dir . '/' . $this->project . '.json';
-
- if (!Storage::has($filename)) {
- return $dir . '/' . static::CONFIG_DEFAULT_FILE;
- }
-
- return $filename;
- }
-
- /**
- * Gets the full path to the configuration file.
- *
- * @return string
- */
- public function loadConfiguration () {
- $fileName = $this->getConfigurationFileName();
-
- $mapper = new \JsonMapper();
- $this->configuration = $mapper->map(
- json_decode(Storage::get($fileName)),
- new PhabricatorPayloadAnalyzerConfiguration()
- );
- }
-
- ///
/// Qualification of the story
///
/**
- * @return bool
- */
- public function isAdministrativeEvent () {
- return false;
- }
-
- /**
* Gets the group for a specific story.
*
* @return string the group, central part of the routing key
*/
public function getGroup () {
- // Some events are organization-level only and can't be mapped
- // to projects.
- if ($this->isAdministrativeEvent()) {
- return $this->configuration->administrativeGroup;
- }
-
// If the payload is about some repository matching a table of
// symbols, we need to sort it to the right group.
- foreach ($this->configuration->groupsMapping as $mapping) {
+ foreach ($this->configuration->map as $mapping) {
foreach ($this->story->getProjects() as $project) {
if ($mapping->doesItemBelong($project)) {
return $mapping->group;
@@ -122,7 +61,7 @@
}
// Words
- foreach ($this->configuration->groupsMapping as $mapping) {
+ foreach ($this->configuration->map as $mapping) {
if ($mapping->doesStoryBelong($this->story)) {
return $mapping->group;
}
@@ -135,4 +74,4 @@
return $this->configuration->defaultGroup;
}
-}
+}
\ No newline at end of file
diff --git a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
--- a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
@@ -2,25 +2,15 @@
namespace Nasqueron\Notifications\Analyzers\Phabricator;
-class PhabricatorPayloadAnalyzerConfiguration {
- /**
- * The group for organization only events
- *
- * @var string
- */
- public $administrativeGroup;
+use Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration;
- /**
- * The default group to fallback for any event not mapped in another group
- *
- * @var string
- */
- public $defaultGroup;
+class PhabricatorPayloadAnalyzerConfiguration extends PayloadAnalyzerConfiguration {
/**
* An array of RepositoryGroupMapping objects to match repositories & groups
*
* @var PhabricatorGroupMapping[]
*/
- public $groupsMapping;
+ public $map;
+
}
diff --git a/storage/app/GitHubPayloadAnalyzer/default.json b/storage/app/GitHubPayloadAnalyzer/default.json
--- a/storage/app/GitHubPayloadAnalyzer/default.json
+++ b/storage/app/GitHubPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "",
- "repositoryMapping": []
+ "map": []
}
diff --git a/storage/app/JenkinsPayloadAnalyzer/default.json b/storage/app/JenkinsPayloadAnalyzer/default.json
--- a/storage/app/JenkinsPayloadAnalyzer/default.json
+++ b/storage/app/JenkinsPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"defaultGroup": "ci",
- "groupsMapping": [],
+ "map": [],
"notifyOnlyOnFailure": []
}
diff --git a/storage/app/PhabricatorPayloadAnalyzer/default.json b/storage/app/PhabricatorPayloadAnalyzer/default.json
--- a/storage/app/PhabricatorPayloadAnalyzer/default.json
+++ b/storage/app/PhabricatorPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "",
- "groupsMapping": []
+ "map": []
}
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
+++ b/tests/Analyzers/GitHub/GitHubPayloadAnalyzerTest.php
@@ -98,15 +98,15 @@
}
///
- /// Test getRepository
+ /// Test getItemName
///
- public function testGetRepositoryWhenEventIsAdministrative () {
- $this->assertEmpty($this->pingAnalyzer->getRepository());
+ public function testGetItemNameWhenEventIsAdministrative () {
+ $this->assertEmpty($this->pingAnalyzer->getItemName());
}
- public function testGetRepositoryWhenEventIsRepositoryRelative () {
- $this->assertSame("public-repo", $this->pushAnalyzer->getRepository());
+ public function testGetItemNameWhenEventIsRepositoryRelative () {
+ $this->assertSame("public-repo", $this->pushAnalyzer->getItemName());
}
///
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerConfigurationTest.php
@@ -37,7 +37,7 @@
public function testProperties () {
$this->assertSame("ci", $this->configuration->defaultGroup);
- foreach ($this->configuration->groupsMapping as $item) {
+ foreach ($this->configuration->map as $item) {
$this->assertInstanceOf(ItemGroupMapping::class, $item);
}
}
diff --git a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
--- a/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Jenkins/JenkinsPayloadAnalyzerTest.php
@@ -31,8 +31,8 @@
$this->analyzer = new JenkinsPayloadAnalyzer("Nasqueron", $this->payload);
}
- public function testGetJobName () {
- $this->assertSame("test-prod-env", $this->analyzer->getJobName());
+ public function testGetItemName () {
+ $this->assertSame("test-prod-env", $this->analyzer->getItemName());
}
public function testGetGroup () {
diff --git a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
rename from tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php
rename to tests/Analyzers/PayloadAnalyzerConfigurationTest.php
--- a/tests/Analyzers/GitHub/GitHubPayloadAnalyzerConfigurationTest.php
+++ b/tests/Analyzers/PayloadAnalyzerConfigurationTest.php
@@ -4,16 +4,16 @@
use Illuminate\Foundation\Testing\WithoutMiddleware;
-use Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzerConfiguration;
+use Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration;
use Nasqueron\Notifications\Analyzers\ItemGroupMapping;
use Nasqueron\Notifications\Tests\TestCase;
-class GitHubPayloadAnalyzerConfigurationTest extends TestCase {
+class PayloadAnalyzerConfigurationTest extends TestCase {
/**
* Configuration
*
- * @var Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzerConfiguration
+ * @var Nasqueron\Notifications\Analyzers\PayloadAnalyzerConfiguration
*/
protected $configuration;
@@ -21,11 +21,11 @@
* 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('Nasqueron')
+ new PayloadAnalyzerConfiguration('Nasqueron')
);
parent::setUp();
@@ -38,7 +38,7 @@
$this->assertSame("orgz", $this->configuration->administrativeGroup);
$this->assertSame("nasqueron", $this->configuration->defaultGroup);
- foreach ($this->configuration->repositoryMapping as $item) {
+ foreach ($this->configuration->map as $item) {
$this->assertInstanceOf(ItemGroupMapping::class, $item);
}
}
diff --git a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
@@ -30,7 +30,7 @@
'strongWords',
];
- $this->mappings = array_combine($keys, $config->groupsMapping);
+ $this->mappings = array_combine($keys, $config->map);
$this->story = $this->getStory();
}
diff --git a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
--- a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
@@ -86,4 +86,11 @@
);
}
+ /**
+ * @expectedException \BadMethodCallException
+ */
+ public function testGetItemThrowsBadMethodCallException () {
+ $this->analyzer->getItemName();
+ }
+
}
diff --git a/tests/data/GitHubPayloadAnalyzer/Nasqueron.json b/tests/data/GitHubPayloadAnalyzer/Nasqueron.json
--- a/tests/data/GitHubPayloadAnalyzer/Nasqueron.json
+++ b/tests/data/GitHubPayloadAnalyzer/Nasqueron.json
@@ -1,7 +1,7 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "nasqueron",
- "repositoryMapping": [
+ "map": [
{
"group": "docker",
"items": [
diff --git a/tests/data/GitHubPayloadAnalyzer/default.json b/tests/data/GitHubPayloadAnalyzer/default.json
--- a/tests/data/GitHubPayloadAnalyzer/default.json
+++ b/tests/data/GitHubPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "",
- "repositoryMapping": []
+ "map": []
}
diff --git a/tests/data/JenkinsPayloadAnalyzer/Nasqueron.json b/tests/data/JenkinsPayloadAnalyzer/Nasqueron.json
--- a/tests/data/JenkinsPayloadAnalyzer/Nasqueron.json
+++ b/tests/data/JenkinsPayloadAnalyzer/Nasqueron.json
@@ -1,6 +1,6 @@
{
"defaultGroup": "ci",
- "groupsMapping": [
+ "map": [
{
"group": "wikidata",
"items": [
diff --git a/tests/data/JenkinsPayloadAnalyzer/default.json b/tests/data/JenkinsPayloadAnalyzer/default.json
--- a/tests/data/JenkinsPayloadAnalyzer/default.json
+++ b/tests/data/JenkinsPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"defaultGroup": "ci",
- "groupsMapping": [],
+ "map": [],
"notifyOnlyOnFailure": []
}
diff --git a/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json b/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json
--- a/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json
+++ b/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json
@@ -1,7 +1,7 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "nasqueron",
- "groupsMapping": [
+ "map": [
{
"group": "docker",
"items": [
diff --git a/tests/data/PhabricatorPayloadAnalyzer/default.json b/tests/data/PhabricatorPayloadAnalyzer/default.json
--- a/tests/data/PhabricatorPayloadAnalyzer/default.json
+++ b/tests/data/PhabricatorPayloadAnalyzer/default.json
@@ -1,5 +1,5 @@
{
"administrativeGroup": "orgz",
"defaultGroup": "",
- "groupsMapping": []
+ "map": []
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 02:44 (1 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2255611
Default Alt Text
D629.id1570.diff (29 KB)

Event Timeline