Permalink
Browse files

Added a test to find out about permission related errors while scanning.

  • Loading branch information...
1 parent 15441d2 commit 88552db4e033d0c754a86450da357e1cedb3e492 @lapistano committed Oct 29, 2011
Showing with 29 additions and 5 deletions.
  1. +24 −3 accepted/tests/Psr0_CompatibilityTest.php
  2. +5 −2 accepted/tests/Psr0_Scanner.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
@@ -13,6 +13,13 @@
class psr0_CompatibilityTest extends \PHPUnit_Framework_TestCase
{
/**
+ * Contains the result of the directory scan.
+ * @staticvar
+ * @var Psr0_Scanner
+ */
+ protected static $psr0;
+
+ /**
* @dataProvider psr0CompatibilityDataprovider
*/
public function testPsr0Compatability($filename, $classname)
@@ -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 */
@@ -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);
}
}
@@ -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;
@@ -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;
}

0 comments on commit 88552db

Please sign in to comment.