Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12373560
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
index fcfe50d..ae88013 100644
--- a/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
+++ b/app/Analyzers/Phabricator/PhabricatorGroupMapping.php
@@ -1,76 +1,76 @@
<?php
namespace Nasqueron\Notifications\Analyzers\Phabricator;
use Nasqueron\Notifications\Phabricator\PhabricatorStory;
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) {
+ if (stripos($story->text, $word) !== false) {
return true;
}
}
return false;
}
}
diff --git a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
index ba8cbd9..12add1a 100644
--- a/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
+++ b/tests/Analyzers/Phabricator/PhabricatorGroupMappingTest.php
@@ -1,115 +1,127 @@
<?php
namespace Nasqueron\Notifications\Tests\Analyzers\Phabricator;
use Nasqueron\Notifications\Analyzers\Phabricator\PhabricatorGroupMapping;
use Nasqueron\Notifications\Tests\TestCase;
class PhabricatorGroupMappingTest extends TestCase {
use WithConfiguration;
/**
* @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(
PhabricatorGroupMapping::doesProjectMatch(
'quux*',
'quuxians'
)
);
$this->assertTrue(
PhabricatorGroupMapping::doesProjectMatch(
'quux*',
'quux'
)
);
$this->assertFalse(
PhabricatorGroupMapping::doesProjectMatch(
'foobar',
'quux'
)
);
$this->assertFalse(
PhabricatorGroupMapping::doesProjectMatch(
'',
'quuxians'
)
);
$this->assertFalse(
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)
);
}
+ /**
+ * Test to fix T773
+ */
+ public function testDoesStoryBelongWhenWordIsInAnotherCase () {
+ $mapping = $this->mappings['words'];
+
+ $this->story->text = "Review the Cartography elements.";
+ $this->assertTrue(
+ $mapping->doesStoryBelong($this->story)
+ );
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 1, 17:53 (1 d, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3116963
Default Alt Text
(5 KB)
Attached To
Mode
rNOTIF Notifications center
Attached
Detach File
Event Timeline
Log In to Comment