/** * @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); }
/** * @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")); }
/** * @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()); }
/** * @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); }
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'); }