Пример #1
0
 /**
  * Removes temporary output files.
  *
  * @return void
  */
 protected function tearDown()
 {
     if (file_exists($this->_out)) {
         unlink($this->_out);
     }
     parent::tearDown();
 }
Пример #2
0
 /**
  * Parses the given source file or directory with the default tokenizer
  * and node builder implementations.
  *
  * @param string  $testCase          Qualified test case name.
  * @param boolean $ignoreAnnotations The parser should ignore annotations.
  *
  * @return PHP_Depend_Code_NodeIterator
  */
 public static function parseTestCaseSource($testCase, $ignoreAnnotations = false)
 {
     list($class, $method) = explode('::', $testCase);
     $parts = explode('_', $class);
     try {
         return parent::parseSource(sprintf('Metrics/%s/%s.php', $parts[count($parts) - 2], $method), $ignoreAnnotations);
     } catch (Exception $e) {
     }
     return parent::parseSource(sprintf('Metrics/%s/%s', $parts[count($parts) - 2], $method), $ignoreAnnotations);
 }
Пример #3
0
 /**
  * Creates temporary test resources.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->cacheDir = self::createRunResourceURI('cacheDir');
     $this->testFile = self::createRunResourceURI('testFile');
 }
Пример #4
0
 /**
  * Parses the given source file or directory with the default tokenizer
  * and node builder implementations.
  *
  * @param string  $testCase          Qualified test case name.
  * @param boolean $ignoreAnnotations The parser should ignore annotations.
  *
  * @return PHP_Depend_Code_NodeIterator
  */
 public static function parseTestCaseSource($testCase, $ignoreAnnotations = false)
 {
     list($class, $method) = explode('::', $testCase);
     return parent::parseSource(sprintf('code/%s/%s.php', substr($class, strrpos($class, '_') + 1, -4), $method), $ignoreAnnotations);
 }
Пример #5
0
 /**
  * Creates the expected metrics array.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $packages = self::parseSource(dirname(__FILE__) . '/../../_code/code-5.2.x');
     $this->_analyzer = new PHP_Depend_Metrics_CodeRank_Analyzer();
     $this->_analyzer->analyze($packages);
     $this->_expected = array();
     foreach ($packages as $package) {
         if ($package->getTypes()->count() === 0) {
             continue;
         }
         $this->_expected[] = array($package, $this->_input[$package->getName()]);
         foreach ($package->getTypes() as $type) {
             $this->_expected[] = array($type, $this->_input[$type->getName()]);
         }
     }
 }
Пример #6
0
            $fileOrDirectory = self::createCodeResourceURI($fileOrDirectory);
        }
        if (is_dir($fileOrDirectory)) {
            $it = new PHP_Depend_Input_Iterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fileOrDirectory)), new PHP_Depend_Input_ExcludePathFilter(array('.svn')));
        } else {
            $it = new ArrayIterator(array($fileOrDirectory));
        }
        $files = array();
        foreach ($it as $file) {
            if (is_object($file)) {
                $files[] = realpath($file->getPathname());
            } else {
                $files[] = $file;
            }
        }
        sort($files);
        $builder = new PHP_Depend_Builder_Default();
        foreach ($files as $file) {
            $tokenizer = new PHP_Depend_Tokenizer_Internal();
            $tokenizer->setSourceFile($file);
            $parser = new PHP_Depend_Parser($tokenizer, $builder);
            if ($ignoreAnnotations === true) {
                $parser->setIgnoreAnnotations();
            }
            $parser->parse();
        }
        return $builder->getPackages();
    }
}
PHP_Depend_AbstractTest::init();
Пример #7
0
 /**
  * Removes the temporary log files.
  *
  * @return void
  */
 protected function tearDown()
 {
     @unlink($this->resultFile);
     parent::tearDown();
 }
Пример #8
0
 /**
  * Initializes a temporary workling directory.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->cacheDir = self::createRunResourceURI('cache');
     $this->versionFile = "{$this->cacheDir}/_version";
 }
Пример #9
0
 /**
  * Restores the original working directory.
  *
  * @return void
  */
 protected function tearDown()
 {
     chdir($this->workingDir);
     parent::tearDown();
 }
Пример #10
0
 /**
  * Sets up the code builder.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $packages = self::parseSource(dirname(__FILE__) . '/../../_code/mixed_code.php');
     foreach ($packages as $pkg) {
         if (isset($this->_input[$pkg->getUUID()])) {
             $this->_expected[$pkg->getUUID()] = $this->_input[$pkg->getName()];
         }
     }
 }
Пример #11
0
 /**
  * Restores the original include path.
  *
  * @return void
  */
 protected function tearDown()
 {
     set_include_path($this->includePath);
     foreach (spl_autoload_functions() as $callback) {
         if (is_array($callback) && $callback[0] instanceof PHP_Depend_Autoload) {
             spl_autoload_unregister($callback);
         }
     }
     parent::tearDown();
 }
Пример #12
0
 /**
  * Parses test code for the calling test case.
  *
  * @param string  $testCase          Name of the calling test case.
  * @param boolean $ignoreAnnotations Should the parser ignore annotations?
  *
  * @return PHP_Depend_Code_NodeIterator
  */
 public static function parseTestCaseSource($testCase, $ignoreAnnotations = false)
 {
     list($className, $methodName) = explode('::', $testCase);
     $directory = substr($className, 18, -4);
     return parent::parseSource("parser/{$directory}/{$methodName}.php", $ignoreAnnotations);
 }
 /**
  * Initializes a list of expected exception messages.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->expectedExceptions = array(sprintf('Unexpected token: function, line: 7, col: 41, file: %s.', self::createCodeResourceURI('issues/061/UnexpectedTokenInParameterDefaultValue.php')));
 }
Пример #14
0
 /**
  * Removes the temporary log files.
  *
  * @return void
  */
 protected function tearDown()
 {
     // Clear filter collection
     $collection = PHP_Depend_Code_Filter_Collection::getInstance();
     $collection->clear();
     @unlink($this->resultFile);
     parent::tearDown();
 }