protected function setUp() { $this->repo = new InMemoryRepository(); $this->repo->add('/webmozart/puli', new DirectoryResource(__DIR__ . '/Fixtures')); $this->assetFactory = new PuliAssetFactory($this->repo, __DIR__ . '/Fixtures'); $this->twig = new RandomizedTwigEnvironment(new PuliTemplateLoader($this->repo)); $this->twig->addExtension(new AsseticExtension($this->assetFactory, array(), null, true)); $this->twig->addExtension(new PuliExtension($this->repo)); $this->twig->addExtension(new PuliAsseticExtension($this->repo)); }
public function testAddCollectionClonesChildrenAttachedToAnotherRepository() { $otherRepo = $this->getMock('Puli\\Repository\\Api\\ResourceRepository'); $file1 = new TestFile('/file1'); $file2 = new TestFile('/file2'); $file2->attachTo($otherRepo); $this->repo->add('/webmozart/puli', new ArrayResourceCollection(array($file1, $file2))); $this->assertSame($file1, $this->repo->get('/webmozart/puli/file1')); $this->assertNotSame($file2, $this->repo->get('/webmozart/puli/file2')); $this->assertSame('/file2', $file2->getPath()); $clone = clone $file2; $clone->attachTo($this->repo, '/webmozart/puli/file2'); $this->assertEquals($clone, $this->repo->get('/webmozart/puli/file2')); }
/** * @param Resource[] $resources * * @return InMemoryRepository */ protected function createRepository(array $resources = array()) { $repo = new InMemoryRepository(); foreach ($resources as $resource) { $repo->add($resource->getPath(), $resource); } return $repo; }
/** * @dataProvider getYears */ public function testListLongFormatsYearDependingOnCurrentYear(DateTime $timestamp, $formattedYear) { $args = self::$lsCommand->parseArgs(new StringArgs('-l /app')); $this->repo->add('/app', new TestDirectory('/app', array($dir1 = new TestDirectory('/app/dir1')))); $dir1->getMetadata()->setModificationTime((int) $timestamp->format('U')); $dir1->getMetadata()->setSize(12); $statusCode = $this->handler->handle($args, $this->io); $expected = <<<EOF TestDirectory 12 Feb 3 {$formattedYear} dir1 EOF; $this->assertSame(0, $statusCode); $this->assertSame($expected, $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }
public function testPrintTreeWithAbsolutePath() { $args = self::$treeCommand->parseArgs(new StringArgs('/app')); $this->repo->add('/app', new TestDirectory('/app', array(new TestDirectory('/app/dir1', array(new TestFile('/app/dir1/file1'))), new TestDirectory('/app/dir2', array(new TestFile('/app/dir2/file1'), new TestFile('/app/dir2/file2'))), new TestFile('/app/file'), new TestFile('/app/resource1'), new TestFile('/app/resource2')))); $expected = <<<EOF /app ├── dir1 │ └── file1 ├── dir2 │ ├── file1 │ └── file2 ├── file ├── resource1 └── resource2 8 resources EOF; $this->assertSame(0, $this->handler->handle($args, $this->io)); $this->assertSame($expected, $this->io->fetchOutput()); $this->assertEmpty($this->io->fetchErrors()); }
protected function setUp() { $this->repo = new InMemoryRepository(); $this->repo->add('/webmozart/puli', new DirectoryResource(self::$fixturesDir)); $this->factory = new PuliAssetFactory($this->repo, self::$fixturesDir); }
/** * @param string $query * @param BindingType $type * @param array $parameters * @param string $language * * @return AbstractBinding */ protected function createBinding($query, BindingType $type, array $parameters = array(), $language = 'glob') { $repo = new InMemoryRepository(); $repo->add($query, new TestFile($query)); return new LazyBinding($query, $repo, $type, $parameters, $language); }