Skip to content

Commit

Permalink
Added a test to find out about permission related errors while scanning.
Browse files Browse the repository at this point in the history
  • Loading branch information
lapistano committed Oct 29, 2011
1 parent 15441d2 commit 88552db
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
27 changes: 24 additions & 3 deletions accepted/tests/Psr0_CompatibilityTest.php
@@ -1,6 +1,6 @@
<?php
/**
* Test case containing test to verify PSR-0 copatibility of a projext.
* Test case containing test to verify PSR-0 copatibility of a project.
*
* @author Bastian Feder <lapistano@php.net>
* @copyright 2011 by Bastian Feder
Expand All @@ -12,6 +12,13 @@

class psr0_CompatibilityTest extends \PHPUnit_Framework_TestCase
{
/**
* Contains the result of the directory scan.
* @staticvar
* @var Psr0_Scanner
*/
protected static $psr0;

/**
* @dataProvider psr0CompatibilityDataprovider
*/
Expand All @@ -27,6 +34,20 @@ public function testPsr0Compatability($filename, $classname)
);
}

/**
* Checks if any permission related errors were registered.
*/
public function testReadErrorsOccured()
{
$errors = self::$psr0->getErrors('NotReadable');
$this->assertEmpty(
$errors,
"The following files could not been readed probably due to missing access permissions:\n\n".
implode(", \n", $errors).
"\n"
);
}


/*************************************************************************/
/* Dataprovider */
Expand All @@ -40,11 +61,11 @@ public function testPsr0Compatability($filename, $classname)
public static function psr0CompatibilityDataprovider()
{
// preparations
$psr0 = new Psr0_Scanner(
self::$psr0 = new Psr0_Scanner(
defined(Psr0_ScannerInclude) ? Psr0_ScannerInclude : '',
defined(Psr0_ScannerExclude) ? Psr0_ScannerExclude : ''
);

return $psr0->scan(Psr0_ScannerStartDir);
return self::$psr0->scan(Psr0_ScannerStartDir);
}
}
7 changes: 5 additions & 2 deletions accepted/tests/Psr0_Scanner.php
Expand Up @@ -16,7 +16,7 @@ class Psr0_Scanner
protected $registry = array();
protected $errors = array();

public function __construct($includes = '' , $excludes = '')
public function __construct($includes = '', $excludes = '')
{
$this->includes = $includes;
$this->excludes = $excludes;
Expand Down Expand Up @@ -57,8 +57,11 @@ public function scan($dir)
*
* @return array
*/
public function getErrors()
public function getErrors($type = '')
{
if (!empty($type) && isset($this->errors[$type])) {
return $this->errors[$type];
}
return $this->errors;
}

Expand Down

0 comments on commit 88552db

Please sign in to comment.