public function testPathResolver() { $fs = new Filesystem(); $root = $this->_root . '/'; $virtPath = new Path(); $virtPath->set('default', $root); runBench(array('new path (new obj and dir)' => function () use($fs, $root) { $newDir = $root . mt_rand(); $fs->mkdir($newDir); // start $virtPath = new Path(); $virtPath->set('default', $newDir); $result = $virtPath->get('default:'); // end return $result; }, 'same path (new)' => function () use($fs, $root) { $virtPath = new Path(); $virtPath->set('default', $root); $result = $virtPath->get('default:'); return $result; }, 'same path' => function () use($fs, $root, $virtPath) { $result = $virtPath->get('default:'); return $result; }), array('count' => 1000, 'name' => 'path resolver')); }
/** * Setup test data */ public function setUp() { $_SERVER['HTTP_HOST'] = 'test.dev'; $_SERVER['REQUEST_URI'] = '/request'; $this->_fixtPath = PROJECT_ROOT . '/tests/fixtures'; $this->_cachePath = PROJECT_ROOT . '/build/cache'; // cleanup $this->_fs = new Filesystem(); $this->_fs->remove($this->_cachePath); $this->_fs->mkdir($this->_cachePath); // Prepare lib $this->_path = new Path(); $this->_path->setRoot($this->_fixtPath); $this->_path->set('assets', 'root:assets'); $this->_manager = new Manager($this->_path); $this->_factory = $this->_manager->getFactory(); $this->_collection = $this->_manager->getCollection(); }
public function testRelativeGlob() { $path = new Path(); $path->setRoot(__DIR__ . '/..'); $path->set('somepath', __DIR__ . '/..'); $path->set('src', 'somepath:src'); $paths = $path->relGlob('somepath:src/*.php'); $this->_is(array('src/Exception.php', 'src/Path.php'), $paths); }