-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from philwc/add-tests
Add tests
- Loading branch information
Showing
20 changed files
with
682 additions
and
111 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.0/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true"> | ||
<testsuite name="default"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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
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
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,38 @@ | ||
<?php | ||
|
||
|
||
namespace PhpDocBlockChecker\FileProvider; | ||
|
||
trait ExcludeFileTrait | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
protected $excludes = []; | ||
|
||
/** | ||
* @param string $baseDirectory | ||
* @param \SplFileInfo $file | ||
* @return bool | ||
*/ | ||
protected function isFileExcluded($baseDirectory, \SplFileInfo $file) | ||
{ | ||
if ($file->getExtension() !== 'php') { | ||
return true; | ||
} | ||
|
||
$filePath = str_replace($baseDirectory, '', $file->getPathname()); | ||
|
||
if (in_array($filePath, $this->excludes, true)) { | ||
return true; | ||
} | ||
|
||
foreach ($this->excludes as $pattern) { | ||
if (fnmatch($pattern, $filePath)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
|
||
namespace PhpDocBlockChecker\FileProvider; | ||
|
||
use Iterator; | ||
|
||
class FileExclusionFilter extends \FilterIterator | ||
{ | ||
use ExcludeFileTrait; | ||
/** | ||
* @var string | ||
*/ | ||
private $baseDirectory; | ||
|
||
/** | ||
* FileExclusionFilter constructor. | ||
* @param Iterator $iterator | ||
* @param string $baseDirectory | ||
* @param array $excludes | ||
*/ | ||
public function __construct(Iterator $iterator, $baseDirectory, array $excludes) | ||
{ | ||
parent::__construct($iterator); | ||
$this->baseDirectory = $baseDirectory; | ||
$this->excludes = $excludes; | ||
} | ||
|
||
/** | ||
* Check whether the current element of the iterator is acceptable | ||
* @link https://php.net/manual/en/filteriterator.accept.php | ||
* @return bool true if the current element is acceptable, otherwise false. | ||
* @since 5.1.0 | ||
*/ | ||
public function accept() | ||
{ | ||
$file = $this->getInnerIterator()->current(); | ||
return !$this->isFileExcluded($this->baseDirectory, $file); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.