Page MenuHomeDevCentral

No OneTemporary

diff --git a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
index bcca513..549d1fb 100644
--- a/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorPayloadAnalyzerTest.php
@@ -1,46 +1,89 @@
<?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 testGetConfigurationFileName () {
+ $this->assertSame(
+ "PhabricatorPayloadAnalyzer/Nasqueron.json",
+ $this->analyzer->getConfigurationFileName()
+ );
+ }
+
+ public function testGetGroupWhereEventIsAdministrative () {
+ $this->markTestIncomplete(
+ "Not yet implemented feature. See T664."
+ );
+
+ $this->assertSame(
+ "orgz",
+ $this->analyzer->getGroup()
+ );
+ }
+
+ public function testGetGroupWhereStoryDoesntMatchAnything () {
+ $this->attachProjectsToStoryMock($this->story, []);
+ $this->assertSame(
+ "nasqueron",
+ $this->analyzer->getGroup()
+ );
+ }
+
+ public function testGetGroupWhereStoryMatchesProject () {
+ $this->attachProjectsToStoryMock($this->story, ['Docker images']);
+ $this->assertSame(
+ "docker",
+ $this->analyzer->getGroup()
+ );
+ }
+
+ public function testGetGroupWhereStoryMatchesWords () {
+ $this->attachProjectsToStoryMock($this->story, []);
+ $this->story->text = "Review the cartography elements.";
+ $this->assertSame(
+ "tasacora",
+ $this->analyzer->getGroup()
+ );
+ }
+
public function testGetGroupWhereWordsAreStrong () {
$this->markTestIncomplete(
- "Not yet implemented feature. See D748."
+ "Not yet implemented feature. See T748."
);
- $this->story->projects = ['Docker images'];
+ $this->attachProjectsToStoryMock($this->story, ['Docker images']);
$this->story->text = "Review the cartography elements on Dwellers.";
$this->assertSame(
"ops",
$this->analyzer->getGroup()
);
}
}
diff --git a/tests/Analyzers/Phabricator/WithConfiguration.php b/tests/Analyzers/Phabricator/WithConfiguration.php
index 91c84dd..c7987a1 100644
--- a/tests/Analyzers/Phabricator/WithConfiguration.php
+++ b/tests/Analyzers/Phabricator/WithConfiguration.php
@@ -1,26 +1,36 @@
<?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");
+ return $this
+ ->getMockBuilder("Nasqueron\Notifications\Phabricator\PhabricatorStory")
+ ->setConstructorArgs(["https://phab.acme"])
+ ->getMock();
+ }
+
+ private function attachProjectsToStoryMock ($mock, $projects) {
+ $mock
+ ->expects($this->any())
+ ->method("getProjects")
+ ->will($this->returnValue($projects));
}
}

File Metadata

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

Event Timeline