Exemple #1
0
 /**
  * Wraps both <code>addTest()</code> and <code>addTestSuite</code>
  * as well as the separate import statements for the user's convenience.
  *
  * If the named file cannot be read or there are no new tests that can be
  * added, a <code>PHPUnit_Framework_Warning</code> will be created instead,
  * leaving the current test run untouched.
  *
  * @param  string  $filename
  * @param  boolean $syntaxCheck
  * @param  array   $phptOptions Array with ini settings for the php instance
  *                              run, key being the name if the setting,
  *                              value the ini value.
  * @throws InvalidArgumentException
  */
 public function addTestFile($filename, $syntaxCheck = FALSE, $phptOptions = array())
 {
     if (!is_string($filename)) {
         throw \PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
     }
     // Ensure we can read the file
     if (!$filename || !is_readable($filename)) {
         throw new \RuntimeException(sprintf('Cannot open file "%s".' . "\n", $filename));
     }
     // Try to convert it to a relative path
     if (strpos($filename, getcwd()) === 0) {
         $filename = substr($filename, strlen(getcwd()) + 1);
     } else {
         if (strpos($filename, './') === 0) {
             $filename = substr($filename, strlen('./'));
         }
     }
     // Use stream wrapper for spec files
     $furl = Spec::SCHEME . '://' . $filename;
     // Setup the environment to collect tests
     \DrSlump\Spec::reset($this);
     \PHPUnit_Util_Fileloader::load($furl);
     $this->numTests = -1;
 }