url() public static méthode

prepends the scheme to the given URL
public static url ( string $path ) : string
$path string path to translate to vfsStream url
Résultat string
 /**
  * {@inheritdoc}
  */
 public function _setUpFiles($structure = NULL)
 {
     $structure = $structure ?: ['tmp' => []];
     $this->root = vfsStream::setup('root', 0777, $structure);
     $this->adapter = new TempFileAdapter($this->root->url() . '/tmp/', 'bmtest_');
     $this->manager = new TempFileManager($this->adapter);
 }
 /**
  * @Given :arg1 security
  */
 public function security($securityName)
 {
     $this->securityName = $securityName;
     \org\bovigo\vfs\vfsStream::setup('home');
     $this->container = \Dgafka\Fixtures\Application\DIContainer::getInstance();
     $this->applicationCore = new \Dgafka\AuthorizationSecurity\Application\Core(new \Dgafka\AuthorizationSecurity\Application\CoreConfig(array(\org\bovigo\vfs\vfsStream::url('home')), \org\bovigo\vfs\vfsStream::url('home/cache'), true));
     switch ($securityName) {
         case 'role':
             $this->applicationCore->registerSecurityType('role', function () {
                 return new \Dgafka\AuthorizationSecurity\Domain\Security\Type\StandardSecurity();
             });
             break;
         case 'lattice':
             $this->applicationCore->registerSecurityType('lattice', function () {
                 return new \Dgafka\AuthorizationSecurity\Domain\Security\Type\StandardSecurity();
             });
             break;
         case 'ibac':
             $this->applicationCore->registerSecurityType('ibac', function () {
                 return new \Dgafka\Fixtures\IBAC\IBACSecurity($this->userPermission);
             });
             break;
         default:
             throw new \Exception("Operation not permitted");
     }
 }
 /**
  * We ignore items that are not covered by the map.
  */
 public function testLoadUncovered()
 {
     vfsStream::setup('StaticMapTestLoadUncovered', null, ['a.php' => '<?php']);
     $object = new StaticMap(['A' => vfsStream::url('a.php'), 'B' => vfsStream::url('Covered.php')]);
     $object->load('StaticMapTestLoadUncoveredC_XYZ');
     $this->assertFalse(class_exists('StaticMapTestLoadUncoveredC_XYZ', false));
 }
Exemple #4
0
 /**
  * Provides Mutex factories.
  *
  * @return callable[][] The mutex factories.
  */
 public function provideMutexFactories()
 {
     $cases = ["NoMutex" => [function () {
         return new NoMutex();
     }], "TransactionalMutex" => [function () {
         $pdo = new \PDO("sqlite::memory:");
         $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         return new TransactionalMutex($pdo);
     }], "FlockMutex" => [function () {
         vfsStream::setup("test");
         return new FlockMutex(fopen(vfsStream::url("test/lock"), "w"));
     }], "SemaphoreMutex" => [function () {
         return new SemaphoreMutex(sem_get(ftok(__FILE__, "a")));
     }], "SpinlockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(SpinlockMutex::class, ["test"]);
         $mock->expects($this->any())->method("acquire")->willReturn(true);
         $mock->expects($this->any())->method("release")->willReturn(true);
         return $mock;
     }], "LockMutex" => [function () {
         $mock = $this->getMockForAbstractClass(LockMutex::class);
         $mock->expects($this->any())->method("lock")->willReturn(true);
         $mock->expects($this->any())->method("unlock")->willReturn(true);
         return $mock;
     }]];
     if (getenv("MEMCACHE_HOST")) {
         $cases["MemcacheMutex"] = [function () {
             $memcache = new Memcache();
             $memcache->connect(getenv("MEMCACHE_HOST"));
             return new MemcacheMutex("test", $memcache);
         }];
         $cases["MemcachedMutex"] = [function () {
             $memcache = new Memcached();
             $memcache->addServer(getenv("MEMCACHE_HOST"), 11211);
             return new MemcachedMutex("test", $memcache);
         }];
     }
     if (getenv("REDIS_URIS")) {
         $uris = explode(",", getenv("REDIS_URIS"));
         $cases["PredisMutex"] = [function () use($uris) {
             $clients = array_map(function ($uri) {
                 return new Client($uri);
             }, $uris);
             return new PredisMutex($clients, "test");
         }];
         $cases["PHPRedisMutex"] = [function () use($uris) {
             $apis = array_map(function ($uri) {
                 $redis = new Redis();
                 $uri = parse_url($uri);
                 if (!empty($uri["port"])) {
                     $redis->connect($uri["host"], $uri["port"]);
                 } else {
                     $redis->connect($uri["host"]);
                 }
                 return $redis;
             }, $uris);
             return new PHPRedisMutex($apis, "test");
         }];
     }
     return $cases;
 }
    /**
     * {@inheritdoc}
     */
    public function testLoad()
    {
        $xml = <<<'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<mediatypes>
    <mediatype name="mp4" category="video">
        <mimetypes>
            <mimetype>video/mp4</mimetype>
        </mimetypes>
    </mediatype>
    <mediatype name="jpg" category="image">
        <mimetypes>
            <mimetype>image/jpg</mimetype>
            <mimetype>image/jpeg</mimetype>
        </mimetypes>
    </mediatype>
</mediatypes>
EOF;
        vfsStream::setup('root', null, ['types.xml' => $xml]);
        $mediatypes = $this->loader->load(vfsStream::url('root/types.xml'));
        $this->assertCount(2, $mediatypes);
        $this->assertTrue($mediatypes->has('video:mp4'));
        $this->assertSame('mp4', $mediatypes->get('video:mp4')->getName());
        $this->assertSame('video', $mediatypes->get('video:mp4')->getCategory());
        $this->assertCount(1, $mediatypes->get('video:mp4')->getMimetypes());
        $this->assertSame(['video/mp4'], $mediatypes->get('video:mp4')->getMimetypes());
        $this->assertTrue($mediatypes->has('image:jpg'));
        $this->assertSame('jpg', $mediatypes->get('image:jpg')->getName());
        $this->assertSame('image', $mediatypes->get('image:jpg')->getCategory());
        $this->assertCount(2, $mediatypes->get('image:jpg')->getMimetypes());
        $this->assertSame(['image/jpg', 'image/jpeg'], $mediatypes->get('image:jpg')->getMimetypes());
    }
 /**
  * @test
  */
 public function directoryIsCreated()
 {
     $example = new Example('id');
     $this->assertFalse($this->root->hasChild('id'));
     $example->setDirectory(vfsStream::url('exampleDir'));
     $this->assertTrue($this->root->hasChild('id'));
 }
 /**
  * @test
  * @param array $structure
  * @param array $excludePattern
  * @param array $expected
  * @dataProvider getChecksumsForPathReturnsChecksumForFilesDataProvider
  */
 public function getChecksumsForPathReturnsChecksumForFiles(array $structure, array $excludePattern, array $expected)
 {
     $baseDirectory = vfsStream::url($this->baseDirectory);
     $this->createTestStructure($baseDirectory, $structure);
     $this->assertSame($expected, $this->generator->getChecksumsForPath($baseDirectory, $excludePattern));
     $this->assertSame($expected, $this->generator->getChecksumsForPath($baseDirectory . '/', $excludePattern));
 }
 /**
  * @test
  */
 public function testThrowsExceptionIfTargetDirectoryExists()
 {
     $instance = new ExtensionGenerator();
     $instance->setTargetFolder(vfsStream::url('temp'));
     $this->setExpectedException('RuntimeException');
     $instance->generate();
 }
Exemple #9
0
 public function setUp()
 {
     parent::setUp();
     vfsStream::setup('home');
     $root_folder = pathinfo(__DIR__);
     $this->root_folder = dirname(dirname($root_folder['dirname']));
     $this->nx = new nx();
     $this->container_original = $this->nx->container;
     $this->nx->root_folder = vfsStream::url('home');
     // See issue at https://github.com/mikey179/vfsStream/issues/44
     $this->nx->container['ini_writer_lock'] = FALSE;
     // Make sure internet is accessible even when there is no internet.
     $this->nx->container['internet_connection_google'] = '127.0.0.1';
     $this->nx->container['internet_connection_nortaox'] = '127.0.0.1';
     // Make sure any attempt of reaching a real endpoint will fail.
     $this->nx->container['config_producao_uri'] = '127.0.0.1';
     $this->response_login = new stdclass();
     $this->response_login->raw_body = '{"sessid":"t8SphFm_tI68qeqJPXzyAaOcxLvsOKV11YGP4W30eLk","session_name":"SESSdd678b24d9cb922c1a48db93fe3ce2e7","token":"kczgr5yuI0JkfFus9MrIWWHMesabJiE6IUQLYwXpFi4","user":{"uid":"87","name":"Francisco Luz","mail":"*****@*****.**","theme":"","signature":"","signature_format":"filtered_html","created":"1415747279","access":"1421795869","login":1421795893,"status":"1","timezone":"America/Cuiaba","language":"pt-br","picture":{"fid":"286","uid":"0","filename":"picture-87-1415747279.jpg","uri":"public://pictures/picture-87-1415747279.jpg","filemime":"application/octet-stream","filesize":"9007","status":"1","timestamp":"1415747279","type":"default","rdf_mapping":[],"url":"http://loja.nortaox.local/sites/loja.nortaox.com/files/pictures/picture-87-1415747279.jpg"},"data":{"hybridauth":{"identifier":"114344118552170824273","webSiteURL":null,"profileURL":"https://plus.google.com/114344118552170824273","photoURL":"https://lh6.googleusercontent.com/-nlf7IN6DkvY/AAAAAAAAAAI/AAAAAAAAAR0/KEoIJgf_PgI/photo.jpg?sz=200","displayName":"Francisco Luz","description":"","firstName":"Francisco","lastName":"Luz","gender":"other","language":"en","age":"","birthDay":0,"birthMonth":0,"birthYear":0,"email":"*****@*****.**","emailVerified":"*****@*****.**","phone":"","address":"Paranagu\\u00e1, PR, Brazil","country":"","region":"","city":"Paranagu\\u00e1, PR, Brazil","zip":"","provider":"Google"},"contact":1,"ckeditor_default":"t","ckeditor_show_toggle":"t","ckeditor_width":"100%","ckeditor_lang":"en","ckeditor_auto_lang":"t","overlay":1},"roles":{"2":"authenticated user","4":"merchant"},"rdf_mapping":{"rdftype":["sioc:UserAccount"],"name":{"predicates":["foaf:name"]},"homepage":{"predicates":["foaf:page"],"type":"rel"}},"realname":"Francisco Luz"}}';
     $this->response_login->code = 200;
     $this->response_login->body = new stdclass();
     $this->response_login->body->sessid = 't8SphFm_tI68qeqJPXzyAaOcxLvsOKV11YGP4W30eLk';
     $this->response_login->body->session_name = 'SESSdd678b24d9cb922c1a48db93fe3ce2e7';
     $this->response_login->body->token = 'kczgr5yuI0JkfFus9MrIWWHMesabJiE6IUQLYwXpFi4';
     $this->nx->container['request_login'] = function ($c) {
         return $this->response_login;
     };
 }
 public static function setUpBeforeClass()
 {
     /* Setup virtual file system. */
     vfsStream::setup('root/');
     /* Modify root path to point to the virtual file system. */
     Core\Config()->modifyPath('root', vfsStream::url('root/'));
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     vfsStream::setup('home');
     $file = vfsStream::url('home/static.log');
     file_put_contents($file, 'The new contents of the file');
     $this->object = new FileStorage($file, true);
 }
 public function testLoad()
 {
     $initialContent = array('some content');
     vfsStream::create(array('file1' => json_encode($initialContent)), $this->root);
     $content = (new JsonFileLoader())->load(vfsStream::url('test/file1'));
     $this->assertEquals($initialContent, $content);
 }
Exemple #13
0
 /**
  * @covers Imbo\EventListener\ImageVariations\Storage\Filesystem::deleteImageVariations
  */
 public function testDoesNotThrowWhenDeletingNonExistantVariation()
 {
     $dir = 'basedir';
     vfsStream::setup($dir);
     $adapter = new Filesystem(['dataDir' => vfsStream::url($dir)]);
     $this->assertFalse($adapter->deleteImageVariations('pub', 'img'));
 }
Exemple #14
0
 /**
  * Store an item.
  */
 public function testRemoveItemException()
 {
     $params = array('dir' => vfsStream::url(self::STORAGE_DIR), 'expiration' => 0);
     $storage = new File($params);
     $storage->setItem('foo', 'foo');
     self::assertTrue($storage->removeItem('foo'));
 }
Exemple #15
0
 public function testSimpleVfsRequest()
 {
     vfsStream::setup('root', null, array('robots.txt' => 'ROBOTS WELCOME'));
     $driver = $this->createDriver("GET /robots.txt HTTP/1.1\r\n\r\n", array(1), vfsStream::url("root"));
     $options = array('list_directories' => true, 'list_root_directory' => false, 'run_browser' => false, 'keep_alive' => false, 'timeout' => 4, 'poll_interval' => 1, 'show_banner' => true, 'name' => null);
     $driver->runLimited($options);
     $runTime = date("D, d M Y H:i:s T");
     $handler = $driver->getNetworkHandler();
     $actual = $handler->bucket;
     $actualLines = explode("\r\n", $actual);
     $this->assertEquals('HTTP/1.1 200 OK', $actualLines[0]);
     $expectedBody = "ROBOTS WELCOME";
     $expectedBodyHash = md5($expectedBody);
     $expectedHeaders = array('Server: StupidHttp', 'Date: ' . $runTime, 'Content-Length: ' . strlen($expectedBody), 'Content-MD5: ' . base64_encode($expectedBodyHash), 'Content-Type: text/plain', 'ETag: ' . $expectedBodyHash, 'Last-Modified: ' . $runTime, 'Connection: close');
     $i = 1;
     while (true) {
         if (strlen($actualLines[$i]) == 0) {
             break;
         }
         $this->assertContains($actualLines[$i], $expectedHeaders);
         ++$i;
     }
     $this->assertEquals($expectedBody, $actualLines[$i + 1]);
     $this->assertEquals($i + 2, count($actualLines));
 }
 /**
  * This test creates an extension based on a JSON file, generated
  * with version 1.0 of the ExtensionBuilder and compares all
  * generated files with the originally created ones
  * This test should help, to find compatibility breaking changes
  *
  * @test
  */
 function generateExtensionFromVersion3Configuration()
 {
     $this->configurationManager = $this->getMock($this->buildAccessibleProxy('EBT\\ExtensionBuilder\\Configuration\\ConfigurationManager'), array('dummy'));
     $this->extensionSchemaBuilder = $this->objectManager->get('EBT\\ExtensionBuilder\\Service\\ExtensionSchemaBuilder');
     $testExtensionDir = $this->fixturesPath . 'TestExtensions/test_extension_v3/';
     $jsonFile = $testExtensionDir . \EBT\ExtensionBuilder\Configuration\ConfigurationManager::EXTENSION_BUILDER_SETTINGS_FILE;
     if (file_exists($jsonFile)) {
         // compatibility adaptions for configurations from older versions
         $extensionConfigurationJSON = json_decode(file_get_contents($jsonFile), TRUE);
         $extensionConfigurationJSON = $this->configurationManager->fixExtensionBuilderJSON($extensionConfigurationJSON, FALSE);
     } else {
         $extensionConfigurationJSON = array();
         $this->fail('JSON file not found');
     }
     $this->extension = $this->extensionSchemaBuilder->build($extensionConfigurationJSON);
     $this->fileGenerator->setSettings(array('codeTemplateRootPath' => PATH_typo3conf . 'ext/extension_builder/Resources/Private/CodeTemplates/Extbase/', 'extConf' => array('enableRoundtrip' => '0')));
     $newExtensionDir = vfsStream::url('testDir') . '/';
     $this->extension->setExtensionDir($newExtensionDir . 'test_extension/');
     $this->fileGenerator->build($this->extension);
     $referenceFiles = \TYPO3\CMS\Core\Utility\GeneralUtility::getAllFilesAndFoldersInPath(array(), $testExtensionDir);
     foreach ($referenceFiles as $referenceFile) {
         $createdFile = str_replace($testExtensionDir, $this->extension->getExtensionDir(), $referenceFile);
         if (!in_array(basename($createdFile), array('ExtensionBuilder.json'))) {
             $referenceFileContent = str_replace(array('2011-08-11T06:49:00Z', '2011-08-11', '###YEAR###', '2014'), array(date('Y-m-d\\TH:i:00\\Z'), date('Y-m-d'), date('Y'), date('Y')), file_get_contents($referenceFile));
             $this->assertFileExists($createdFile, 'File ' . $createdFile . ' was not created!');
             // do not compare files that contain a formatted DateTime, as it might have changed between file creation and this comparison
             if (strpos($referenceFile, 'xlf') === FALSE && strpos($referenceFile, 'yaml') === FALSE) {
                 $originalLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $referenceFileContent, TRUE);
                 $generatedLines = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, file_get_contents($createdFile), TRUE);
                 $this->assertEquals($originalLines, $generatedLines, 'File ' . $createdFile . ' was not equal to original file.');
             }
         }
     }
 }
Exemple #17
0
 /**
  * Tests the YAML file discovery.
  */
 public function testDiscovery()
 {
     vfsStreamWrapper::register();
     $root = new vfsStreamDirectory('modules');
     vfsStreamWrapper::setRoot($root);
     $url = vfsStream::url('modules');
     mkdir($url . '/test_1');
     file_put_contents($url . '/test_1/test_1.test.yml', 'name: test');
     file_put_contents($url . '/test_1/test_2.test.yml', 'name: test');
     mkdir($url . '/test_2');
     file_put_contents($url . '/test_2/test_3.test.yml', 'name: test');
     // Write an empty YAML file.
     file_put_contents($url . '/test_2/test_4.test.yml', '');
     // Set up the directories to search.
     $directories = array('test_1' => $url . '/test_1', 'test_2' => $url . '/test_1', 'test_3' => $url . '/test_2', 'test_4' => $url . '/test_2');
     $discovery = new YamlDiscovery('test', $directories);
     $data = $discovery->findAll();
     $this->assertEquals(count($data), count($directories));
     $this->assertArrayHasKey('test_1', $data);
     $this->assertArrayHasKey('test_2', $data);
     $this->assertArrayHasKey('test_3', $data);
     $this->assertArrayHasKey('test_4', $data);
     foreach (array('test_1', 'test_2', 'test_3') as $key) {
         $this->assertArrayHasKey('name', $data[$key]);
         $this->assertEquals($data[$key]['name'], 'test');
     }
     $this->assertSame(array(), $data['test_4']);
 }
Exemple #18
0
 public function testGetTranslations_shouldReturnEmptyArray()
 {
     $root = vfsStream::setup('root');
     $root->addChild(new vfsStreamFile('language.php'));
     $obj = new Language_File(vfsStream::url('root/language.php'));
     $this->assertEquals(array(), $obj->getTranslations());
 }
 /**
  * Try to load a class that is outside the namespace.
  */
 public function testLoadOutside()
 {
     vfsStream::setup('root', null, ['NS' => ['A' => ['B.php' => '<?php class BPSRLoadExists_XYZ {}', 'C.php' => '<?php']]]);
     $object = new PSR0Namespace(vfsStream::url('root'), 'NS');
     $object->load('NS\\A\\D');
     $this->assertFalse(class_exists('NS\\A\\D', false));
 }
 /**
  * @param string $className
  * @dataProvider provider
  */
 public function testGeneratesTestCodeCorrectly($className)
 {
     $generatedFile = vfsStream::url('root') . '/' . $className . 'Test.php';
     $generator = new TestGenerator($className, __DIR__ . '/_fixture/_input/' . $className . '.php', $className . 'Test', $generatedFile);
     $generator->write();
     $this->assertStringMatchesFormatFile(__DIR__ . '/_fixture/_expected/' . $className . 'Test.php', file_get_contents($generatedFile));
 }
Exemple #21
0
 public function testFactoryIpFilter()
 {
     $this->init(array('logger' => array($this->key => array('path' => vfsStream::url('logs/default.log'), 'ip' => '255.*'))));
     $logger = $this->factory->createServiceWithName($this->serviceLocator, $this->key, $this->key);
     $logger->debug('Test');
     $this->assertEquals("", file_get_contents(vfsStream::url('logs/default.log')));
 }
    /**
     * @covers phpDocumentor\Plugin\Core\Transformer\Writer\CheckStyle::transform
     */
    public function testTransform()
    {
        $transformer = m::mock('phpDocumentor\\Transformer\\Transformation');
        $transformer->shouldReceive('getTransformer->getTarget')->andReturn(vfsStream::url('CheckStyleTest'));
        $transformer->shouldReceive('getArtifact')->andReturn('artifact.xml');
        $fileDescriptor = m::mock('phpDocumentor\\Descriptor\\FileDescriptor');
        $projectDescriptor = m::mock('phpDocumentor\\Descriptor\\ProjectDescriptor');
        $projectDescriptor->shouldReceive('getFiles->getAll')->andReturn(array($fileDescriptor));
        $error = m::mock('phpDocumentor\\Descriptor\\Validator\\Error');
        $fileDescriptor->shouldReceive('getPath')->andReturn('/foo/bar/baz');
        $fileDescriptor->shouldReceive('getAllErrors->getAll')->andReturn(array($error));
        $error->shouldReceive('getLine')->andReturn(1234);
        $error->shouldReceive('getCode')->andReturn(5678);
        $error->shouldReceive('getSeverity')->andReturn('error');
        $error->shouldReceive('getContext')->andReturn('myContext');
        $this->translator->shouldReceive('translate')->with('5678')->andReturn('5678 %s');
        // Call the actual method
        $this->checkStyle->transform($projectDescriptor, $transformer);
        // Assert file exists
        $this->assertTrue($this->fs->hasChild('artifact.xml'));
        // Inspect XML
        $xml = <<<XML
<?xml version="1.0"?>
<checkstyle version="1.3.0">
  <file name="/foo/bar/baz">
    <error line="1234" severity="error" message="5678 myContext" source="phpDocumentor.file.5678"/>
  </file>
</checkstyle>
XML;
        $expectedXml = new \DOMDocument();
        $expectedXml->loadXML($xml);
        $actualXml = new \DOMDocument();
        $actualXml->load(vfsStream::url('CheckStyleTest/artifact.xml'));
        $this->assertEqualXMLStructure($expectedXml->firstChild, $actualXml->firstChild, true);
    }
 public function testRemove()
 {
     $strategy = $this->getMockForAbstractClass('Corley\\MaintenanceBundle\\Maintenance\\Strategy\\BaseStrategy');
     file_put_contents(vfsStream::url('web/a'), "MAINTENANCE");
     $strategy->remove(vfsStream::url('web/a'));
     $this->assertFalse(file_exists(vfsStream::url('web/a')));
 }
Exemple #24
0
 public function url($path)
 {
     if ($this->isRootReal) {
         return $this->root . '/' . $path;
     }
     return vfsStream::url($this->root . '/' . $path);
 }
Exemple #25
0
 public function setUp(DiInterface $di = NULL, Config $config = NULL)
 {
     vfsStream::setup('root');
     vfsStream::newFile('file.php')->at(vfsStreamWrapper::getRoot());
     $this->file = vfsStream::url('root/file.php');
     parent::setUp($di, $config);
 }
Exemple #26
0
 /**
  * Setup the test
  */
 public function setUp()
 {
     vfsStream::setup('root', null, array('test' => 'testing'));
     $this->file = vfsStream::url('root/test');
     $this->properties = $this->getMock('\\Pants\\Property\\Properties');
     $this->task = new Copy($this->properties);
 }
Exemple #27
0
 /**
  * Sets up the test fixture.
  *
  * @return void
  */
 public function setUp()
 {
     vfsStreamWrapper::register();
     vfsStreamWrapper::setRoot(new vfsStreamDirectory('test'));
     $this->forum = 'test';
     $this->contents = new Forum_Contents(vfsStream::url('test'));
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->dir = vfsStream::setup();
     $dir = $this->dir;
     $tempDir = vfsStream::url($dir->getName()) . '/';
     $this->media = $this->getMock('\\Oryzone\\MediaStorage\\Model\\MediaInterface');
     $this->media->expects($this->any())->method('getContext')->will($this->returnValue('default'));
     $this->media->expects($this->any())->method('getName')->will($this->returnValue('sample'));
     $this->media->expects($this->any())->method('getContent')->will($this->returnValue('http://vimeo.com/56974716'));
     $this->media->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('id', null, '56974716'))));
     $this->variant = $this->getMock('\\Oryzone\\MediaStorage\\Variant\\VariantInterface');
     $this->variant->expects($this->any())->method('getName')->will($this->returnValue('default'));
     $this->variant->expects($this->any())->method('getOptions')->will($this->returnValue(array('width' => 50, 'height' => 30, 'resize' => 'stretch')));
     $this->variant->expects($this->any())->method('getMetaValue')->will($this->returnValueMap(array(array('width', null, 50), array('height', null, 30))));
     $image = $this->getMock('\\Imagine\\Image\\ImageInterface');
     $image->expects($this->any())->method('save')->will($this->returnCallback(function ($destFile) use($dir) {
         $temp = vfsStream::newFile(basename($destFile));
         $dir->addChild($temp);
         return true;
     }));
     $imagine = $this->getMock('\\Imagine\\Image\\ImagineInterface');
     $imagine->expects($this->any())->method('open')->will($this->returnValue($image));
     $downloader = $this->getMock('\\Oryzone\\MediaStorage\\Downloader\\DownloaderInterface');
     $downloader->expects($this->any())->method('download')->will($this->returnCallback(function ($url, $destination) use($dir) {
         $temp = vfsStream::newFile(basename($destination));
         $temp->setContent(file_get_contents(__DIR__ . '/../fixtures/images/sample.jpg'));
         $dir->addChild($temp);
         return true;
     }));
     $videoService = $this->getMock('\\Oryzone\\MediaStorage\\Integration\\Video\\VideoServiceInterface');
     $this->provider = new VimeoProvider($tempDir, $imagine, $videoService, $downloader);
 }
 /**
  * @test
  */
 public function parse()
 {
     vfsStream::newFile('file1', '644')->setContent("test file1")->at($this->root);
     vfsStream::newFile('file2', '644')->setContent("test file1")->at($this->root);
     $parser = new DirectoryParser();
     $this->assertEquals([['add', 'file1', 'file1'], ['add', 'file2', 'file2']], $parser->parse(vfsStream::url('root')));
 }
 public function testWriteFailsWhenThereIsAProblemWithSymfonyYamlDumper()
 {
     $yamlWriterProvider = new YamlWriterProvider($this->mockWriter);
     $this->mockWriter->expects($this->once())->method('dump')->with(array('result' => false))->willThrowException(new DumpException());
     $this->setExpectedException('JGimeno\\TaskReporter\\Infrastructure\\Exception\\YamlProviderException');
     $yamlWriterProvider->write(vfsStream::url('settings/config.yml'), array('result' => false));
 }