Skip to content

Commit 37b04f3

Browse files
committed
Fix multiquery
Fix multiquery Fix multiquery
1 parent 33393fb commit 37b04f3

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

spec/Knp/PhpSpec/WellDone/Locator/ResourceInspectorSpec.php

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ class ResourceInspectorSpec extends ObjectBehavior
99
{
1010
/**
1111
* @param PhpSpec\Locator\PSR0\PSR0Resource $resource
12+
* @param PhpSpec\Locator\PSR0\PSR0Resource $resource2
1213
* @param Knp\PhpSpec\WellDone\Util\Filesystem $filesystem
1314
**/
14-
function let($resource, $filesystem)
15+
function let($resource, $resource2, $filesystem)
1516
{
1617
$resource->getSpecFilename()->willReturn('spec/The/Path.php');
1718
$resource->getSrcFilename()->willReturn('src/The/Path.php');
19+
$resource->getSrcClassname()->willReturn('The\Path');
20+
21+
$resource2->getSrcClassname()->willReturn('The\PathType');
1822

1923
$this->beConstructedWith($filesystem);
2024
}
@@ -78,4 +82,30 @@ function it_should_detect_if_resource_is_not_abstract($resource, $filesystem)
7882

7983
$this->isAbstract($resource)->shouldReturn(false);
8084
}
85+
86+
public function it_should_test_query_matching($resource)
87+
{
88+
$this->matchQuery($resource, '*Path')->shouldReturn(true);
89+
$this->matchQuery($resource, 'The\*')->shouldReturn(true);
90+
$this->matchQuery($resource, '*Pa*')->shouldReturn(true);
91+
}
92+
93+
public function it_should_test_query_not_matching($resource)
94+
{
95+
$this->matchQuery($resource, 'Path')->shouldReturn(false);
96+
$this->matchQuery($resource, 'The/')->shouldReturn(false);
97+
$this->matchQuery($resource, '*path')->shouldReturn(false);
98+
}
99+
100+
public function it_should_test_queries_matching($resource2)
101+
{
102+
$this->matchQueries($resource2, '*Type, App\*, *Controller')->shouldReturn(true);
103+
$this->matchQueries($resource2, '*Type, The\*, *Controller')->shouldReturn(true);
104+
$this->matchQueries($resource2, '*Type, The\*, *Path*')->shouldReturn(true);
105+
}
106+
107+
public function it_should_test_queries_not_matching($resource2)
108+
{
109+
$this->matchQueries($resource2, '*Top, App\*, *Controller')->shouldReturn(false);
110+
}
81111
}

src/Knp/PhpSpec/WellDone/Locator/NoSpecLocator.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ public function findResourcesWithExclusion($query)
2525
return $this->findNotSpecResources($this->getFullSrcPath(), $query);
2626
}
2727

28-
public function supportsExclusionQuery($query)
28+
public function supportsExclusionQuery($query, $delim = ',')
2929
{
30-
$query = preg_replace('/[A-Za-z_\\*]/', '', $query);
31-
return empty($query);
30+
foreach (explode($delim, $query) as $q) {
31+
$q = preg_replace('/[A-Za-z_\\\*]/', '', trim($q));
32+
33+
if (false === empty($q)) {
34+
35+
return false;
36+
}
37+
}
38+
39+
return true;
3240
}
3341

3442
protected function findNotSpecResources($path, $query = null)

src/Knp/PhpSpec/WellDone/Locator/ResourceInspector.php

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public function matchQueries(PSR0Resource $resource, $queries, $delim = ',')
3838
{
3939
foreach (explode($delim, $queries) as $query) {
4040
if (true === $this->matchQuery($resource, trim($query))) {
41-
4241
return true;
4342
}
4443
}

0 commit comments

Comments
 (0)