Beispiel #1
0
 /**
  * Check whether specified classes correspond to a file according PSR-0 standard
  *
  * Cyclomatic complexity is because of temporary marking test as incomplete
  * Suppressing "unused variable" because of the "catch" block
  *
  * @param array $classes
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 protected function _assertClassesExist($classes, $path)
 {
     if (!$classes) {
         return;
     }
     $badClasses = [];
     $badUsages = [];
     foreach ($classes as $class) {
         try {
             if (strrchr($class, '\\') === false and !Classes::isVirtual($class)) {
                 $badUsages[] = $class;
                 continue;
             } else {
                 $this->assertTrue(isset(self::$_existingClasses[$class]) || Files::init()->classFileExists($class) || Classes::isVirtual($class) || Classes::isAutogenerated($class));
             }
             self::$_existingClasses[$class] = 1;
         } catch (\PHPUnit_Framework_AssertionFailedError $e) {
             $badClasses[] = $class;
         }
     }
     if ($badClasses) {
         $this->fail("Files not found for following usages in {$path}:\n" . implode("\n", $badClasses));
     }
     if ($badUsages) {
         $this->fail("Bad usages of classes in {$path}: \n" . implode("\n", $badUsages));
     }
 }