Skip to content

Commit

Permalink
fix(ignore-regexp-filter): bad string concatenation (refs #23)
Browse files Browse the repository at this point in the history
  • Loading branch information
mborne committed Dec 4, 2023
1 parent 93b6729 commit b85b51c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Filter/FilterCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getDescription()
{
$parts = [];
foreach ($this->filters as $filter) {
$parts[] = ' - '.$filter->getDescription();
$parts[] = '- '.$filter->getDescription();
}

return implode(PHP_EOL, $parts);
Expand Down
2 changes: 1 addition & 1 deletion src/Filter/IgnoreRegexpFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct($ignoreRegexp)
*/
public function getDescription()
{
return 'project name should not match /'.$this->ignoreRegexp + '/';
return 'project name should not match /'.$this->ignoreRegexp.'/';
}

/**
Expand Down
17 changes: 13 additions & 4 deletions tests/Filter/FilterCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testEmpty()
*
* @return ProjectFilterInterface
*/
private function createMockFilter($accepted)
private function createMockFilter($accepted, $description = 'mock')
{
$filter = $this->getMockBuilder(ProjectFilterInterface::class)
->getMock()
Expand All @@ -35,6 +35,10 @@ private function createMockFilter($accepted)
->method('isAccepted')
->willReturn($accepted)
;
$filter->expects($this->any())
->method('getDescription')
->willReturn($description)
;

return $filter;
}
Expand All @@ -61,10 +65,15 @@ public function testOneFalse()
public function testTrueFalseTrue()
{
$filterCollection = new FilterCollection(new NullLogger());
$filterCollection->addFilter($this->createMockFilter(true));
$filterCollection->addFilter($this->createMockFilter(false));
$filterCollection->addFilter($this->createMockFilter(true));
$filterCollection->addFilter($this->createMockFilter(true, 'mock-1'));
$filterCollection->addFilter($this->createMockFilter(false, 'mock-2'));
$filterCollection->addFilter($this->createMockFilter(true, 'mock-3'));
$project = $this->createMockProject('test');
$this->assertFalse($filterCollection->isAccepted($project));

$this->assertEquals(
'- mock-1'.PHP_EOL.'- mock-2'.PHP_EOL.'- mock-3',
$filterCollection->getDescription()
);
}
}
5 changes: 5 additions & 0 deletions tests/Filter/IgnoreRegexpFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public function testExample()
{
$filter = new IgnoreRegexpFilter('(^phpstorm|^typo3\/library)');

$this->assertEquals(
'project name should not match /(^phpstorm|^typo3\/library)/',
$filter->getDescription()
);

$expectedResults = [
'mborne/sample-project' => true,
'something' => true,
Expand Down

0 comments on commit b85b51c

Please sign in to comment.