/** * @covers Alchemy\Zippy\Resource\ResourceManager::handle */ public function testFunctionnal() { $wd = __DIR__; $tmpdir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR); $filesystem = new \Symfony\Component\Filesystem\Filesystem(); $filesystem->mkdir($tmpdir . '/path/to/local/'); $filesystem->mkdir($tmpdir . '/to/'); $filesystem->mkdir($tmpdir . '/path/to/a'); touch($tmpdir . '/path/to/local/file.ext'); touch($tmpdir . '/path/to/local/file2.ext'); touch($tmpdir . '/to/file3.ext'); $request = array($wd . '/input/path/to/local/file.ext', $wd . '/input/path/to/a/../local/file2.ext', $tmpdir . '/path/to/local/file.ext', $tmpdir . '/path/to/a/../local/file2.ext', 'http://www.google.com/+/business/images/plus-badge.png', 'http://www.google.com/+/business/images/plusone-button.png', 'file://' . $tmpdir . '/to/file3.ext', 'file://' . $wd . '/input/path/to/a/../local/file3.ext', '/I/want/this/file/to/go/there' => 'file://' . $wd . '/input/path/to/local/file2.ext', '/I/want/this/file/to/go/here' => 'file://' . $wd . '/input/path/to/local/file3.ext'); $expected = array('input/path/to/local/file.ext', 'input/path/to/local/file2.ext', 'file.ext', 'file2.ext', 'plus-badge.png', 'plusone-button.png', 'file3.ext', 'input/path/to/local/file3.ext', 'I/want/this/file/to/go/there', 'I/want/this/file/to/go/here'); $expectedSource = array($request[0], $request[1], $request[2], $request[3], $request[4], $request[5], $request[6], $request[7], $request['/I/want/this/file/to/go/there'], $request['/I/want/this/file/to/go/here']); $resourceManger = ResourceManager::create(); $collection = $resourceManger->handle($wd, $request); $this->assertCount(10, $collection); $n = 0; foreach ($collection as $resource) { $this->assertEquals($expected[$n], $resource->getTarget()); $this->assertEquals($expectedSource[$n], $resource->getOriginal()); $n++; } }
/** * Returns a new instance of the invoked adapter * * @return AbstractAdapter * * @throws RuntimeException In case object could not be instanciated */ public static function newInstance() { return new ZipExtensionAdapter(ResourceManager::create()); }