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'));
 }
 public function testListChildren()
 {
     $repo = $this->getMock('Puli\\Repository\\Api\\ResourceRepository');
     $resource1 = new TestFile('/path/to/dir/file1');
     $resource2 = new TestFile('/path/to/dir/file2');
     $this->repo->mount('/webmozart', $repo);
     $repo->expects($this->once())->method('listChildren')->with('/path/to/dir')->will($this->returnValue(new ArrayResourceCollection(array($resource1, $resource2))));
     $expected = new ArrayResourceCollection(array($resource1->createReference('/webmozart/path/to/dir/file1'), $resource2->createReference('/webmozart/path/to/dir/file2')));
     $this->assertEquals($expected, $this->repo->listChildren('/webmozart/path/to/dir'));
 }
Example #3
0
    public function testListLong()
    {
        $args = self::$lsCommand->parseArgs(new StringArgs('-l /app'));
        $this->repo->add('/app', new TestDirectory('/app', array($dir1 = new TestDirectory('/app/dir1'), $file1 = new TestFile('/app/file1'), $file2 = new TestFile('/app/file2'))));
        $dir1->getMetadata()->setModificationTime(1234);
        $dir1->getMetadata()->setSize(12);
        $file1->getMetadata()->setModificationTime(2345);
        $file1->getMetadata()->setSize(34);
        $file2->getMetadata()->setModificationTime(3456);
        $file2->getMetadata()->setSize(56);
        $statusCode = $this->handler->handle($args, $this->io);
        $expected = <<<EOF
TestDirectory 12 Jan 1 1970 dir1
TestFile      34 Jan 1 1970 file1
TestFile      56 Jan 1 1970 file2

EOF;
        $this->assertSame(0, $statusCode);
        $this->assertSame($expected, $this->io->fetchOutput());
        $this->assertEmpty($this->io->fetchErrors());
    }