/** * Load config test. */ public function testLoadConfig() { $logFile = $this->makeFile($this->baseTempDir, 'hook.log'); $logger = new Logger('git-web-hook'); $logger->pushHandler(new StreamHandler($logFile, Logger::WARNING)); $hook = new Hook(__DIR__, array(), $logger); $reposDir = $this->makeTempDir('repos.d'); $testFile = $this->makeFile($reposDir, 'test3.yml'); $this->generateRepoConfigFile($testFile, 3); $mainConfigFile = $this->makeFile($this->baseTempDir, 'main_config.yml'); file_put_contents($mainConfigFile, $this->configTemplates->render('config1.php', array('reposDir' => $reposDir))); $hook->loadConfig($mainConfigFile); $options = $hook->getOptions(); $this->assertFalse($options['sendEmails'], 'Wrong loaded configuration option sendEmails '); $this->assertFalse($options['sendEmailAuthor'], 'Wrong loaded configuration option sendEmailAuthor'); $repository = $hook->getRepository('git@github.com:amaxlab/git-web-hook-test.git'); $this->assertNotNull($repository, 'Repository was not loaded through config.yml '); $this->assertInstanceOf('AmaxLab\\GitWebHook\\Repository', $repository, 'It is not a repository object'); $masterBranch = $repository->getBranch('master'); $productionBranch = $repository->getBranch('production'); $this->assertInstanceOf('AmaxLab\\GitWebHook\\Branch', $masterBranch, 'There is not a branch master'); $this->assertInstanceOf('AmaxLab\\GitWebHook\\Branch', $productionBranch, 'There is not a branch master'); $this->assertContains('*****@*****.**', $masterBranch->getOptions()['mailRecipients']); $this->assertContains('192.168.0.2', Request::getTrustedProxies(), 'There is error in configuring trusted proxies'); $this->assertContains('192.168.0.3', Request::getTrustedProxies(), 'There is error in configuring trusted proxies'); $this->assertNotContains('192.168.0.4', Request::getTrustedProxies(), 'There is error in configuring trusted proxies'); $content = file_get_contents($logFile); $this->assertEmpty($content, sprintf('Log file is not empty: %s', $content)); }