コード例 #1
0
 public function testNotName()
 {
     $finder = new Finder();
     $this->assertSame($finder, $finder->notName('*.php'));
     $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
     $finder = new Finder();
     $finder->notName('*.php');
     $finder->notName('*.py');
     $this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->in(self::$tmpDir)->getIterator());
     $finder = new Finder();
     $finder->name('test.ph*');
     $finder->name('test.py');
     $finder->notName('*.php');
     $finder->notName('*.py');
     $this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
 }
コード例 #2
0
ファイル: WebTestCase.php プロジェクト: pgodel/PageRoller
 /**
  * Creates a Kernel.
  *
  * If you run tests with the PHPUnit CLI tool, everything will work as expected.
  * If not, override this method in your test classes.
  *
  * Available options:
  *
  *  * environment
  *  * debug
  *
  * @param array $options An array of options
  *
  * @return Symfony\Components\HttpKernel\HttpKernelInterface A HttpKernelInterface instance
  */
 protected function createKernel(array $options = array())
 {
     // black magic below, you have been warned!
     $dir = getcwd();
     if (!isset($_SERVER['argv']) || false === strpos($_SERVER['argv'][0], 'phpunit')) {
         throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
     }
     // find the --configuration flag from PHPUnit
     $cli = implode(' ', $_SERVER['argv']);
     if (preg_match('/\\-\\-configuration[= ]+([^ ]+)/', $cli, $matches)) {
         $dir = $dir . '/' . dirname($matches[1]);
     }
     $finder = new Finder();
     $finder->name('*Kernel.php')->in($dir);
     if (!count($finder)) {
         throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
     }
     $file = current(iterator_to_array($finder));
     $class = $file->getBasename('.php');
     unset($finder);
     require_once $file;
     return new $class(isset($options['environment']) ? $options['environment'] : 'test', isset($options['debug']) ? $debug : true);
 }