Example #1
0
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage No search criteria specified
  */
 public function testFailIfNoCriteria()
 {
     $args = self::$findCommand->parseArgs(new StringArgs(''));
     $this->repo->expects($this->never())->method('find');
     $this->discovery->expects($this->never())->method('findByType');
     $this->handler->handle($args, $this->io);
 }
 protected function setUp()
 {
     $tempnam = tempnam(sys_get_temp_dir(), 'ResourceStreamWrapperTest');
     file_put_contents($tempnam, self::FILE_CONTENTS);
     $this->repo = $this->getMock('Puli\\Repository\\Api\\ResourceRepository');
     $this->repo->expects($this->any())->method('get')->will($this->returnCallback(function ($path) use($tempnam) {
         if ('/webmozart/puli/file' === $path) {
             return new FileResource($tempnam, '/webmozart/puli/file');
         }
         if ('/webmozart/puli/non-local' === $path) {
             return new TestFile('/webmozart/puli/non-local');
         }
         if ('/webmozart/puli/dir' === $path) {
             return new TestDirectory('/webmozart/puli/dir', array(new TestFile('/webmozart/puli/dir/file1'), new TestFile('/webmozart/puli/dir/file2')));
         }
         if ('/webmozart/puli/dir2' === $path) {
             return new TestDirectory('/webmozart/puli/dir2', array(new TestFile('/webmozart/puli/dir2/.dotfile'), new TestFile('/webmozart/puli/dir2/foo'), new TestFile('/webmozart/puli/dir2/bar')));
         }
         throw new ResourceNotFoundException();
     }));
 }