本文整理汇总了PHP中org\bovigo\vfs\vfsStream::url方法的典型用法代码示例。如果您正苦于以下问题:PHP vfsStream::url方法的具体用法?PHP vfsStream::url怎么用?PHP vfsStream::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org\bovigo\vfs\vfsStream
的用法示例。
在下文中一共展示了vfsStream::url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setUpFiles
/**
* {@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);
}
示例2: security
/**
* @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");
}
}
示例3: testLoadUncovered
/**
* 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));
}
示例4: provideMutexFactories
/**
* 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;
}
示例5: testLoad
/**
* {@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());
}
示例6: directoryIsCreated
/**
* @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'));
}
示例7: getChecksumsForPathReturnsChecksumForFiles
/**
* @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));
}
示例8: testThrowsExceptionIfTargetDirectoryExists
/**
* @test
*/
public function testThrowsExceptionIfTargetDirectoryExists()
{
$instance = new ExtensionGenerator();
$instance->setTargetFolder(vfsStream::url('temp'));
$this->setExpectedException('RuntimeException');
$instance->generate();
}
示例9: setUp
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":"drupalista.com.br@gmail.com","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":"drupalista.com.br@gmail.com","emailVerified":"drupalista.com.br@gmail.com","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;
};
}
示例10: setUpBeforeClass
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/'));
}
示例11: setUp
/**
* 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);
}
示例12: testLoad
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);
}
示例13: testDoesNotThrowWhenDeletingNonExistantVariation
/**
* @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'));
}
示例14: testRemoveItemException
/**
* 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'));
}
示例15: testSimpleVfsRequest
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));
}