/** * Returns a parsed configuration if one was found in the current folder or generates an error * message to send back * * @param Folder $folder the current folder * @param string $configName name of the configuration file * @param array $config the configuration collected so far * @param int $level the starting level is 0 and we add 1 each time we visit a parent folder * * @return array */ private function buildFolderConfig($folder, $configName, $config, $level) { try { list($config, $completionStatus) = $this->configParser->getFolderConfig($folder, $configName, $config, $this->completionStatus, $level); $this->completionStatus = $completionStatus; } catch (ConfigException $exception) { $config = $this->buildErrorMessage($exception, $folder); } return $config; }
private function mockGetFolderConfigWithBrokenSetup($folder, $configName, $config, $configItems, $level, $exception) { $this->configParser->expects($this->any())->method('getFolderConfig')->with($folder, $configName, $config, $configItems, $level)->willThrowException($exception); }
/** * @dataProvider providesGetFolderConfigData * * @param $currentConfig * @param $configItems * @param $newConfig * @param $level * @param $expectedResult */ public function testGetFolderConfig($currentConfig, $configItems, $newConfig, $level, $expectedResult) { $folder = $this->mockFolderWithConfig($newConfig); $response = $this->configParser->getFolderConfig($folder, $this->configName, $currentConfig, $configItems, $level); $this->assertEquals($expectedResult, $response); }