public function testAddInput_NonFile() { $input = new \vc\App\Paths(); try { $input->addInput(\r8\FileSys::create($this->dir . '/NotAFile')); $this->fail("An expected exception was not thrown"); } catch (\r8\Exception\Argument $err) { } }
/** * Builds the configuration * * @return \vc\App\Config */ public function build(\r8\CLI\Result $cli) { if ($cli->countArgs() < 2) { throw new \r8\Exception\Argument(0, 'CLI Args', 'Less than two arguments given'); } $args = $cli->getArgs(); $output = new \r8\FileSys\Dir(array_shift($args)); $paths = new \vc\App\Paths(); foreach ($args as $path) { $paths->addInput(\r8\FileSys::create($path)); } return new \vc\App\Config($output, $paths); }
public function testCreate() { $dir = \r8\FileSys::create(__DIR__); $this->assertThat($dir, $this->isInstanceOf('r8\\FileSys\\Dir')); $this->assertEquals(__DIR__ . "/", $dir->getPath()); $newDir = \r8\FileSys::create($dir); $this->assertThat($newDir, $this->isInstanceOf('r8\\FileSys\\Dir')); $this->assertNotSame($dir, $newDir); $this->assertEquals(__DIR__ . "/", $newDir->getPath()); $file = \r8\FileSys::create(__FILE__); $this->assertThat($file, $this->isInstanceOf('r8\\FileSys\\File')); $this->assertEquals(__FILE__, $file->getPath()); $newFile = \r8\FileSys::create($file); $this->assertThat($newFile, $this->isInstanceOf('r8\\FileSys\\File')); $this->assertNotSame($file, $newFile); $this->assertEquals(__FILE__, $newFile->getPath()); $file = \r8\FileSys::create("/path/to/the/abyss"); $this->assertThat($file, $this->isInstanceOf('r8\\FileSys\\File')); $this->assertEquals("/path/to/the/abyss", $file->getPath()); }
/** * Returns the file represented by this instance * * @return \r8\FileSys */ public function getFile() { if (!isset($this->file)) { $this->file = \r8\FileSys::create($this->base . "/" . $this->path); $this->file->resolve(); } return clone $this->file; }