-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test FilterCollection and simplify test organization (#20)
- Loading branch information
Showing
10 changed files
with
113 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...nal/Command/GitlabToConfigCommandTest.php → tests/Command/GitlabToConfigCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Tests\SatisGitlab\Filter; | ||
|
||
use Tests\SatisGitlab\TestCase; | ||
|
||
use Psr\Log\NullLogger; | ||
|
||
use MBO\SatisGitlab\Filter\FilterCollection; | ||
use MBO\SatisGitlab\Git\ProjectInterface; | ||
use MBO\SatisGitlab\Filter\ProjectFilterInterface; | ||
|
||
/** | ||
* Test FilterCollection | ||
*/ | ||
class FilterCollectionTest extends TestCase { | ||
|
||
public function testEmpty(){ | ||
$filterCollection = new FilterCollection(new NullLogger()); | ||
$project = $this->createMockProject('test'); | ||
$this->assertTrue($filterCollection->isAccepted($project)); | ||
} | ||
|
||
/** | ||
* Create a fake project filter returning true or false | ||
* | ||
* @param boolean $accepted | ||
* @return ProjectFilterInterface | ||
*/ | ||
private function createMockFilter($accepted){ | ||
$filter = $this->getMockBuilder(ProjectFilterInterface::class) | ||
->getMock() | ||
; | ||
$filter->expects($this->any()) | ||
->method('isAccepted') | ||
->willReturn($accepted) | ||
; | ||
return $filter; | ||
} | ||
|
||
|
||
public function testOneTrue(){ | ||
$filterCollection = new FilterCollection(new NullLogger()); | ||
$filterCollection->addFilter($this->createMockFilter(true)); | ||
$project = $this->createMockProject('test'); | ||
$this->assertTrue($filterCollection->isAccepted($project)); | ||
} | ||
|
||
public function testOneFalse(){ | ||
$filterCollection = new FilterCollection(new NullLogger()); | ||
$filterCollection->addFilter($this->createMockFilter(false)); | ||
$project = $this->createMockProject('test'); | ||
$this->assertFalse($filterCollection->isAccepted($project)); | ||
} | ||
|
||
/** | ||
* Check that isAccepted is unanymous | ||
*/ | ||
public function testTrueFalseTrue(){ | ||
$filterCollection = new FilterCollection(new NullLogger()); | ||
$filterCollection->addFilter($this->createMockFilter(true)); | ||
$filterCollection->addFilter($this->createMockFilter(false)); | ||
$filterCollection->addFilter($this->createMockFilter(true)); | ||
$project = $this->createMockProject('test'); | ||
$this->assertFalse($filterCollection->isAccepted($project)); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
tests/functional/Git/GitlabClientTest.php → tests/Git/GitlabClientTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
tests/unit/Satis/ConfigBuilderTest.php → tests/Satis/ConfigBuilderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Tests\SatisGitlab; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
use MBO\SatisGitlab\Git\ProjectInterface; | ||
|
||
class TestCase extends BaseTestCase { | ||
|
||
/** | ||
* Create a fake project with a given name | ||
* | ||
* @param string $projectName | ||
* @return ProjectInterface | ||
*/ | ||
protected function createMockProject($projectName){ | ||
$project = $this->getMockBuilder(ProjectInterface::class) | ||
->getMock() | ||
; | ||
$project->expects($this->any()) | ||
->method('getName') | ||
->willReturn($projectName) | ||
; | ||
return $project; | ||
} | ||
|
||
} |