Page MenuHomeDevCentral

No OneTemporary

diff --git a/app/Analyzers/RepositoryGroupMapping.php b/app/Analyzers/RepositoryGroupMapping.php
index 1d0856f..01c6bf0 100644
--- a/app/Analyzers/RepositoryGroupMapping.php
+++ b/app/Analyzers/RepositoryGroupMapping.php
@@ -1,53 +1,53 @@
<?php
namespace Nasqueron\Notifications\Analyzers;
class RepositoryGroupMapping {
///
/// Properties
///
/**
* The group the mapped repositories belong to
*
* @var string
*/
public $group;
/**
* An array of the repositories, each item a string with the name of the
* repository. The wildcard '*' is allowed to specify several repositories.
*
* @var array
*/
public $repositories;
///
/// Helper methods
///
/**
* Determines if the specified repository matches a pattern
*
- * @param string the pattern, with * and ? allowed
- * @param string the repository name to compare with the pattern
+ * @param string $pattern The pattern, with * allowed as wildcard character
+ * @param string $repository The repository name to compare with the pattern
* @return bool
*/
public static function doesRepositoryMatch ($pattern, $repository) {
- return ($pattern === $repository) || fnmatch($pattern, $repository);
+ return str_is($pattern, $repository);
}
/**
* Determines if the specified repository belong to this mapping
*
* @return bool
*/
public function doesRepositoryBelong ($actualRepository) {
foreach ($this->repositories as $candidateRepository) {
if (static::doesRepositoryMatch($candidateRepository, $actualRepository)) {
return true;
}
}
return false;
}
}
diff --git a/tests/RepositoryGroupMappingTest.php b/tests/RepositoryGroupMappingTest.php
new file mode 100644
index 0000000..d30b57d
--- /dev/null
+++ b/tests/RepositoryGroupMappingTest.php
@@ -0,0 +1,45 @@
+<?php
+
+use Illuminate\Foundation\Testing\WithoutMiddleware;
+
+use Nasqueron\Notifications\Analyzers\RepositoryGroupMapping;
+
+class RepositoryGroupMappingTest extends TestCase {
+
+ public function testDoesRepositoryMatch () {
+ $this->assertTrue(
+ RepositoryGroupMapping::doesRepositoryMatch(
+ 'quux*',
+ 'quuxians'
+ )
+ );
+
+ $this->assertTrue(
+ RepositoryGroupMapping::doesRepositoryMatch(
+ 'quux*',
+ 'quux'
+ )
+ );
+
+ $this->assertFalse(
+ RepositoryGroupMapping::doesRepositoryMatch(
+ 'foobar',
+ 'quux'
+ )
+ );
+
+ $this->assertFalse(
+ RepositoryGroupMapping::doesRepositoryMatch(
+ '',
+ 'quuxians'
+ )
+ );
+
+ $this->assertFalse(
+ RepositoryGroupMapping::doesRepositoryMatch(
+ 'quux*',
+ ''
+ )
+ );
+ }
+}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Sep 18, 02:07 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2989800
Default Alt Text
(3 KB)

Event Timeline