Resources can be added with the method {@link add()}: php use Puli\Repository\InMemoryRepository; $repo = new InMemoryRepository(); $repo->add('/css', new DirectoryResource('/path/to/project/res/css'));
Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends AbstractEditableRepository
 /**
  * @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;
 }
 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 testGenerateNameWithRelativePathDoesNotQueryPuliRepoIfCurrentDirNull()
 {
     $this->repo = $this->getMock('Puli\\Repository\\Api\\ResourceRepository');
     $this->repo->expects($this->never())->method('get');
     $this->factory = new PuliAssetFactory($this->repo, self::$fixturesDir);
     $name = $this->factory->generateAssetName(array('style.css'));
     // Don't use "/webmozart/puli" here, because that also corresponds to
     // the root directory of the factory
     $name->setCurrentDir(null);
     $this->assertNotEmpty($name->__toString());
 }
Example #4
0
    /**
     * @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());
    }
Example #5
0
    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());
    }
 /**
  * @expectedException \Puli\Repository\Api\UnsupportedLanguageException
  * @expectedExceptionMessage foobar
  */
 public function testRemoveFailsIfLanguageNotGlob()
 {
     $repo = new InMemoryRepository();
     $repo->remove('/*', 'foobar');
 }
Example #7
0
 /**
  * @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);
 }