Page MenuHomeDevCentral

D285.diff
No OneTemporary

D285.diff

diff --git a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
+
+use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzer;
+use Nasqueron\Notifications\Tests\TestCase;
+
+class PhabricatorPayloadAnalyzerTest extends TestCase {
+
+ use WithConfiguration;
+
+ /**
+ * @var PhabricatorPayloadAnalyzer
+ */
+ private $analyzer;
+
+ /**
+ * @var PhabricatorStory
+ */
+ private $story;
+
+ public function setUp () {
+ parent::setUp();
+
+ $this->story = $this->getStory();
+ $this->analyzer = new PhabricatorPayloadAnalyzer(
+ "Nasqueron",
+ $this->story
+ );
+ }
+
+ public function testGetGroupWhereWordsAreStrong () {
+ $this->markTestIncomplete(
+ "Not yet implemented feature. See D748."
+ );
+
+ $this->story->projects = ['Docker images'];
+ $this->story->text = "Review the cartography elements on Dwellers.";
+
+ $this->assertSame(
+ "ops",
+ $this->analyzer->getGroup()
+ );
+ }
+
+}
diff --git a/tests/Analyzers/Phabricator/ProjetGroupMappingTest.php b/tests/Analyzers/Phabricator/ProjetGroupMappingTest.php
new file mode 100644
--- /dev/null
+++ b/tests/Analyzers/Phabricator/ProjetGroupMappingTest.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
+
+use Nasqueron\Notifications\Analyzers\Phabricator\ProjectGroupMapping;
+use Nasqueron\Notifications\Tests\TestCase;
+
+class ProjectGroupMappingTest extends TestCase {
+
+ use WithConfiguration;
+
+ /**
+ * @var ProjectGroupMapping|]
+ */
+ 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(
+ 'quux*',
+ 'quuxians'
+ )
+ );
+
+ $this->assertTrue(
+ ProjectGroupMapping::doesProjectMatch(
+ 'quux*',
+ 'quux'
+ )
+ );
+
+ $this->assertFalse(
+ ProjectGroupMapping::doesProjectMatch(
+ 'foobar',
+ 'quux'
+ )
+ );
+
+ $this->assertFalse(
+ ProjectGroupMapping::doesProjectMatch(
+ '',
+ 'quuxians'
+ )
+ );
+
+ $this->assertFalse(
+ ProjectGroupMapping::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)
+ );
+ }
+
+}
diff --git a/tests/Analyzers/Phabricator/WithConfiguration.php b/tests/Analyzers/Phabricator/WithConfiguration.php
new file mode 100644
--- /dev/null
+++ b/tests/Analyzers/Phabricator/WithConfiguration.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
+
+use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorPayloadAnalyzerConfiguration;
+use Nasqueron\Notifications\Phabricator\PhabricatorStory;
+
+/**
+ * Helper methods to construct needed objects
+ */
+trait WithConfiguration {
+
+ private function getPhabricatorPayloadAnalyzerConfiguration () {
+ $filename = __DIR__ . '/../../data/PhabricatorPayloadAnalyzer/Nasqueron.json';
+ $mapper = new \JsonMapper();
+ return $mapper->map(
+ json_decode(file_get_contents($filename)),
+ new PhabricatorPayloadAnalyzerConfiguration('Nasqueron')
+ );
+ }
+
+ private function getStory() {
+ return new PhabricatorStory("https://phab.acme");
+ }
+
+}
diff --git a/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json b/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json
new file mode 100644
--- /dev/null
+++ b/tests/data/PhabricatorPayloadAnalyzer/Nasqueron.json
@@ -0,0 +1,42 @@
+{
+ "administrativeGroup": "orgz",
+ "defaultGroup": "nasqueron",
+ "groupsMapping": [
+ {
+ "group": "docker",
+ "projects": [
+ "Docker images",
+ "Nasqueron Docker deployment squad"
+ ]
+ },
+ {
+ "group": "tasacora",
+ "projects":[
+ "Tasacora"
+ ],
+ "words": [
+ "Tasacora",
+ "cartography"
+ ]
+ },
+ {
+ "group": "ops",
+ "projects": [
+ "Continous integration and delivery",
+ "IPv6",
+ "Mail",
+ "Message queues",
+ "Murasil",
+ "Nasqueron security operations squad",
+ "Servers",
+ "Ops-sprint-*"
+ ],
+ "words": [
+ "Ysul",
+ "Dwellers",
+ "pkg audit"
+ ],
+ "wordsAreStrong": true
+ }
+ ]
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 07:26 (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2262122
Default Alt Text
D285.diff (6 KB)

Event Timeline