public function testFilePermissionsInstaller() { $request = $this->getMock('\\Zend\\Http\\PhpEnvironment\\Request', [], [], '', false); $response = $this->getMock('\\Zend\\Http\\PhpEnvironment\\Response', [], [], '', false); $routeMatch = $this->getMock('\\Zend\\Mvc\\Router\\RouteMatch', [], [], '', false); $mvcEvent = $this->getMock('\\Zend\\Mvc\\MvcEvent', [], [], '', false); $mvcEvent->expects($this->once())->method('setRequest')->with($request)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setResponse')->with($response)->willReturn($mvcEvent); $mvcEvent->expects($this->once())->method('setTarget')->with($this->environment)->willReturn($mvcEvent); $mvcEvent->expects($this->any())->method('getRouteMatch')->willReturn($routeMatch); $this->permissions->expects($this->once())->method('getMissingWritablePathsForInstallation'); $this->environment->setEvent($mvcEvent); $this->environment->dispatch($request, $response); $this->environment->filePermissionsAction(); }
/** * Check permissions of directories that are expected to be writable for installation * * @return void * @throws \Exception */ private function checkInstallationFilePermissions() { $results = $this->filePermissions->getMissingWritablePathsForInstallation(); if ($results) { $errorMsg = "Missing write permissions to the following paths:" . PHP_EOL . implode(PHP_EOL, $results); throw new \Exception($errorMsg); } }
public function testCheckApplicationFilePermissions() { $this->filePermissions->expects($this->once())->method('getUnnecessaryWritableDirectoriesForApplication')->willReturn(['foo', 'bar']); $expectedMessage = "For security, remove write permissions from these directories: 'foo' 'bar'"; $this->logger->expects($this->once())->method('log')->with($expectedMessage); $this->object->checkApplicationFilePermissions(); $this->assertSame(['message' => [$expectedMessage]], $this->object->getInstallInfo()); }
/** * Check permissions of directories that are expected to be non-writable for application * * @return void */ public function checkApplicationFilePermissions() { $results = $this->filePermissions->getUnnecessaryWritableDirectoriesForApplication(); if ($results) { $errorMsg = "For security, remove write permissions from these directories: '" . implode("' '", $results) . "'"; $this->log->log($errorMsg); $this->installInfo[self::INFO_MESSAGE][] = $errorMsg; } }
/** * @param array $mockMethods * @param array $expected * @dataProvider getUnnecessaryWritableDirectoriesForApplicationDataProvider */ public function testGetUnnecessaryWritableDirectoriesForApplication(array $mockMethods, array $expected) { $this->directoryListMock->expects($this->at(0))->method('getPath')->with(DirectoryList::CONFIG)->will($this->returnValue(BP . '/app/etc')); $index = 0; foreach ($mockMethods as $mockMethod => $returnValue) { $this->directoryWriteMock->expects($this->at($index))->method($mockMethod)->will($this->returnValue($returnValue)); $index += 1; } $this->assertEquals($expected, array_values($this->filePermissions->getUnnecessaryWritableDirectoriesForApplication())); }
/** * @expectedException \Exception * @expectedExceptionMessage Missing write permissions to the following paths: */ public function testWritePermissionErrors() { $this->filePermissions->expects($this->once())->method('getMissingWritablePathsForInstallation')->willReturn(['/a/ro/dir', '/media']); $this->configModel->process([]); }