/** * @test * @expectedException \Punkstar\Ssl\Exception * @expectedExceptionCode 2001 */ public function testJunkCert() { $fs = new FileSystem(); $fs->createFile("/junk.crt", "junk-content"); $reader = new Reader(); $reader->readFromFile($fs->path("/junk.crt")); }
public function testDefinitionCache() { $fileSystem = new FileSystem(); $cacheDir = $fileSystem->path('cache'); mkdir($cacheDir); $this->setConfigService(['soflomo_purifier' => ['standalone' => false, 'config' => ['HTML.DefinitionID' => 'custom definitions', 'Cache.SerializerPath' => $cacheDir, 'definitions' => ['HTML' => ['addAttribute' => ['a', 'foo', new HTMLPurifier_AttrDef_Enum(['asd'])]]]]]]); // create the purifier config and get the definition a first time to warm up the cache $purifierConfig = $this->factory->__invoke($this->serviceManager); $purifierConfig->getDefinition('HTML'); $this->assertTrue(is_dir($cacheDir . '/HTML')); $cacheFilesNum = 0; $cacheDirHandle = opendir($cacheDir); while (readdir($cacheDirHandle) !== false) { ++$cacheFilesNum; } $this->assertGreaterThan(0, $cacheFilesNum); // now repeat leaving out the definition config $this->serviceManager = new ServiceManager(); $this->setConfigService(['soflomo_purifier' => ['standalone' => false, 'config' => ['HTML.DefinitionID' => 'custom definitions', 'Cache.SerializerPath' => $cacheDir]]]); $purifierConfig = $this->factory->__invoke($this->serviceManager); /** @var HTMLPurifier_HTMLDefinition $definition */ $definition = $purifierConfig->getDefinition('HTML'); $this->assertInstanceOf('HTMLPurifier_HTMLDefinition', $definition); /** @var HTMLPurifier_ElementDef $elementDefinition */ $elementDefinition = $definition->info['a']; $this->assertInstanceOf('HTMLPurifier_ElementDef', $elementDefinition); /** @var HTMLPurifier_AttrDef_Enum $attributeDefinition */ $attributeDefinition = $elementDefinition->attr['foo']; $this->assertInstanceOf('HTMLPurifier_AttrDef_Enum', $attributeDefinition); }
/** * @test */ public function testDatabasePortParsing() { $fs = new FileSystem(); $fs->createFile("/env.php", $this->getExampleEnvPhpWithPortContent()); $configReader = new MagentoTwo($fs->path("/env.php")); $this->assertEquals("1989", $configReader->getDatabasePort()); $this->assertEquals("db", $configReader->getDatabaseHost()); }
/** * @test */ public function testDatabasePortParsing() { $fs = new FileSystem(); $fs->createFile("/local.xml", $this->getExampleLocalXmlWithPortContent()); $configReader = new MagentoOne($fs->path("/local.xml")); $this->assertEquals("1989", $configReader->getDatabasePort()); $this->assertEquals("db", $configReader->getDatabaseHost()); }
public function it_returns_all_codepoint_assigned_elements() { $fs = new FileSystem(); $path = $fs->path('/ucd.xml'); file_put_contents($path, self::XML_DATA); $xmlReader = new XMLReader($path); $this->beConstructedWith($xmlReader); $this->read()->shouldIterateWithCharacterElements(['0000', '0001', '0002', '0003']); }
public function it_throws_if_the_data_read_back_from_the_file_system_is_not_an_array() { $fs = new FileSystem(); $fileInfo = new \SplFileInfo($fs->path('/r.php')); $file = $fileInfo->openFile('w'); $file->fwrite("<?php\nreturn 'foo';"); $this->beConstructedWith($fileInfo); $this->shouldThrow(UnexpectedValueException::class)->duringReadArray(); }
/** * @test */ public function testGetConfigReader() { $fs = new FileSystem(); $fs->createDirectory("/test/app/etc", true); $fs->createFile("/test/app/etc/local.xml", "example"); $rootDiscovery = new RootDiscovery($fs->path("/test")); $this->assertEquals($fs->path("/test"), $rootDiscovery->getRootDirectory()); $this->assertInstanceOf('Meanbee\\LibMageConf\\ConfigReader', $rootDiscovery->getConfigReader()); }
public function it_can_be_constructed_from_a_directory_path() { $fs = new FileSystem(); $fs->createDirectory('/props'); $fs->createFile('/props/block.php'); $dbPath = new \SplFileInfo($fs->path('/props')); $this->beConstructedThrough('fromPath', [$dbPath]); $this->shouldImplement(PHPPropertyFileDirectory::class); }
public function it_can_be_constructed_from_a_directory_path() { $fs = new FileSystem(); $fs->createDirectory('/db'); $fs->createFile('/db/00000001-00000010!0010.php'); $dbPath = new \SplFileInfo($fs->path('/db')); $this->beConstructedThrough('fromPath', [$dbPath]); $this->shouldImplement(PHPRangeFileDirectory::class); $this->getFiles()->shouldHaveCount(1); }
protected function initUpchuck() { // Setup filesystem $fs = new Vfs(); $this->fs_path = $fs->path('/'); $this->disk = new Filesystem(new Adapter($fs)); // Create upchuck adapter instance $this->helpers = new Helpers(['url_prefix' => '/uploads/']); $manager = new MountManager(['tmp' => $this->disk, 'disk' => $this->disk]); $storage = new Storage($manager, $this->helpers); $this->upchuck_adapter = new Upchuck($this->helpers, $storage, $this->disk); }
/** * @test */ public function testReturnsConfigReader() { $fs = new FileSystem(); $fs->createFile("/local.xml"); $fs->createFile("/env.php"); $factory = new ConfigReader\Factory(); $m1 = $factory->create($fs->path("/local.xml"), MagentoType::MAGENTO_1); $m2 = $factory->create($fs->path("/env.php"), MagentoType::MAGENTO_2); $this->assertInstanceOf('\\Meanbee\\LibMageConf\\ConfigReader', $m1); $this->assertInstanceOf('\\Meanbee\\LibMageConf\\ConfigReader\\MagentoOne', $m1); $this->assertInstanceOf('\\Meanbee\\LibMageConf\\ConfigReader', $m2); $this->assertInstanceOf('\\Meanbee\\LibMageConf\\ConfigReader\\MagentoTwo', $m2); }
public function it_only_presents_files_during_iteration() { $fs = new FileSystem(); $fs->createDirectory('/foo'); $fs->createDirectory('/foo/bar'); $fs->createFile('/foo/baz'); $filePath = $fs->path('/foo/baz'); $dir = new \SplFileInfo($fs->path('/foo')); $this->beConstructedThrough('fromPath', [$dir]); $this->shouldIterateLike([$filePath => new \SplFileInfo($filePath)]); }
public function testTouchNotAllowedIfNotOwnerOrNotWritable() { $fs = new FileSystem(); $file = $fs->createFile('/file'); $file->chown($this->uid + 1); //set to non current $file->chmod(00); $wr = new Wrapper(); $this->assertFalse(@$wr->stream_metadata($fs->path('/file'), STREAM_META_TOUCH, 0), 'Not allowed to touch if not owner and no permission'); $error = error_get_last(); $this->assertStringMatchesFormat('touch: %s: Permission denied', $error['message']); $file->chown($this->uid); $this->assertTrue($wr->stream_metadata($fs->path('/file'), STREAM_META_TOUCH, 0), 'Allowed to touch if owner and no permission'); $file->chown($this->uid + 1); //set to non current $file->chmod(02); $this->assertTrue($wr->stream_metadata($fs->path('/file'), STREAM_META_TOUCH, 0), 'Allowed to touch if not owner but with write permission'); }
/** * @dataProvider adapterProvider */ public function testCanProperlyRemovePathPrefix(VfsAdapter $adapter, FileSystem $filesystem) { $this->assertEquals('foo.txt', $adapter->removePathPrefix($filesystem->scheme() . '://foo.txt')); }