Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Analyzers/Phabricator/ProjectGroupMapping.php b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
similarity index 98%
rename from app/Analyzers/Phabricator/ProjectGroupMapping.php
rename to app/Analyzers/Phabricator/PhabricatorGroupMapping.php
index 9646935..fcfe50d 100644
--- a/app/Analyzers/Phabricator/ProjectGroupMapping.php
+++ b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
@@ -1,76 +1,76 @@
<?php
namespace Nasqueron\Notifications\Analyzers\Phabricator;
use Nasqueron\Notifications\Phabricator\PhabricatorStory;
-class ProjectGroupMapping {
+class PhabricatorGroupMapping {
///
/// Properties
///
/**
* The group the mapped projects belong to
*
* @var string
*/
public $group;
/**
* An array of the projects, each item a string with the name of the
* project. The wildcard '*' is allowed to specify several projects.
*
* @var array
*/
public $projects;
/**
* An array of words, each item a string with a word to find in the story.
*
* @var array
*/
public $words = [];
///
/// Helper methods
///
/**
* Determines if the specified project matches a pattern
*
* @param string $pattern The pattern, with * allowed as wildcard character
* @param string $project The project name to compare with the pattern
* @return bool
*/
public static function doesProjectMatch ($pattern, $project) {
return str_is($pattern, $project);
}
/**
* Determines if the specified project belong to this mapping
*
* @return bool
*/
public function doesProjectBelong ($actualProject) {
foreach ($this->projects as $candidateProject) {
if (static::doesProjectMatch($candidateProject, $actualProject)) {
return true;
}
}
return false;
}
/**
* Determines if the specified story belong to this mapping
*
* @return bool
*/
public function doesStoryBelong (PhabricatorStory $story) {
foreach ($this->words as $word) {
if (strpos($story->text, $word) !== false) {
return true;
}
}
return false;
}
}
diff --git a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
index 7598d45..7584ad7 100644
--- a/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
+++ b/app/Analyzers/Phabricator/PhabricatorPayloadAnalyzerConfiguration.php
@@ -1,26 +1,26 @@
<?php
namespace Nasqueron\Notifications\Analyzers\Phabricator;
class PhabricatorPayloadAnalyzerConfiguration {
/**
* The group for organization only events
*
* @var string
*/
public $administrativeGroup;
/**
* The default group to fallback for any event not mapped in another group
*
* @var string
*/
public $defaultGroup;
/**
* An array of RepositoryGroupMapping objects to match repositories & groups
*
- * @var ProjectGroupMapping[]
+ * @var PhabricatorGroupMapping[]
*/
public $groupsMapping;
}
diff --git a/tests/Analyzers/Phabricator/ProjetGroupMappingTest.php b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
similarity index 82%
rename from tests/Analyzers/Phabricator/ProjetGroupMappingTest.php
rename to tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
index e65199d..ba8cbd9 100644
--- a/tests/Analyzers/Phabricator/ProjetGroupMappingTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
@@ -1,115 +1,115 @@
<?php
namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
-use Nasqueron\Notifications\Analyzers\Phabricator\ProjectGroupMapping;
+use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorGroupMapping;
use Nasqueron\Notifications\Tests\TestCase;
-class ProjectGroupMappingTest extends TestCase {
+class PhabricatorGroupMappingTest extends TestCase {
use WithConfiguration;
/**
- * @var ProjectGroupMapping|]
+ * @var PhabricatorGroupMapping|]
*/
private $mappings;
/**
* @var PhabricatorStory
*/
private $story;
public function setUp () {
parent::setUp();
$config = $this->getPhabricatorPayloadAnalyzerConfiguration();
$keys = [
'projects',
'words',
'strongWords',
];
$this->mappings = array_combine($keys, $config->groupsMapping);
$this->story = $this->getStory();
}
///
/// Tests
///
public function testDoesProjectMatch () {
$this->assertTrue(
- ProjectGroupMapping::doesProjectMatch(
+ PhabricatorGroupMapping::doesProjectMatch(
'quux*',
'quuxians'
)
);
$this->assertTrue(
- ProjectGroupMapping::doesProjectMatch(
+ PhabricatorGroupMapping::doesProjectMatch(
'quux*',
'quux'
)
);
$this->assertFalse(
- ProjectGroupMapping::doesProjectMatch(
+ PhabricatorGroupMapping::doesProjectMatch(
'foobar',
'quux'
)
);
$this->assertFalse(
- ProjectGroupMapping::doesProjectMatch(
+ PhabricatorGroupMapping::doesProjectMatch(
'',
'quuxians'
)
);
$this->assertFalse(
- ProjectGroupMapping::doesProjectMatch(
+ PhabricatorGroupMapping::doesProjectMatch(
'quux*',
''
)
);
}
public function testDoesProjectBelong () {
$mapping = $this->mappings['projects'];
$this->assertFalse(
$mapping->doesProjectBelong("")
);
$this->assertFalse(
$mapping->doesProjectBelong("Tasacora")
);
$this->assertTrue(
$mapping->doesProjectBelong("Docker images")
);
$this->assertFalse(
$mapping->doesProjectBelong("Docker")
);
$this->assertFalse(
$mapping->doesProjectBelong("Docker images quux")
);
}
public function testDoesStoryBelong () {
$mapping = $this->mappings['words'];
$this->assertFalse(
$mapping->doesStoryBelong($this->story)
);
$this->story->text = "Review the cartography elements.";
$this->assertTrue(
$mapping->doesStoryBelong($this->story)
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Feb 28, 20:36 (21 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2447790
Default Alt Text
(6 KB)

Event Timeline