public static function getNewDomainList() { if (function_exists('curl_init')) { $curl = curl_init(); curl_setopt_array($curl, [CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => self::$updateUrl]); $domains = curl_exec($curl); curl_close($curl); } else { $domains = @file_get_contents(self::$updateUrl); } return $domains; }
/** * @depends testDomainsRetrieval */ public function testForcedDomainsUpdate() { $domainList = \Nabble\SemaltBlocker\Updater::getNewDomainList(); file_put_contents($this->blockFile, ''); \Nabble\SemaltBlocker\Updater::$ttl = 60 * 60 * 24 * 9999; // = 9999 days; \Nabble\SemaltBlocker\Updater::update(true); $this->assertStringEqualsFile($this->blockFile, $domainList, 'Blocked file should match online domain list'); }