/** * @covers \NewFrontiers\Framework\Output\Javascript::registerLibrary * @covers \NewFrontiers\Framework\Output\Javascript::requireLibrary * @covers \NewFrontiers\Framework\Output\Javascript::includeRequiredLibraries * @covers \NewFrontiers\Framework\Output\Javascript::includeRegisteredLibrary * @covers \NewFrontiers\Framework\Output\Javascript::getInstance */ public function testExternalLibrary() { Javascript::requireLibrary("nfs.StdControls"); Javascript::requireLibrary("nfs.ExtControls"); Javascript::requireLibrary("nfs.DataControls"); Javascript::requireLibrary("jQuery"); Javascript::requireLibrary("datetimepicker"); Javascript::requireLibrary("magnific"); Javascript::requireLibrary("typeahead"); Javascript::requireLibrary("googlemaps"); Javascript::requireLibrary("jqueryuploader"); Javascript::requireLibrary("ckeditor"); Javascript::requireLibrary("bootstrap-toggle"); Javascript::requireLibrary("bootstrap-star-rating"); Javascript::requireLibrary("code-prettify"); Javascript::requireLibrary("bootstrap-slider"); Javascript::requireLibrary("chosen"); Javascript::requireLibrary("froala"); Javascript::requireLibrary("Chart.js"); $string = $this->getActualOutput(); $this->assertEmpty($string); //Read test configuration for full path Configuration::getInstance()->readConfig(); Javascript::includeRequiredLibraries(); $this->expectOutputRegex('/.*(script)+.*/'); //check that valid html is produced $html = $this->getActualOutput(); $this->assertNotEmpty($html); $dom = new \DOMDocument(); $dom->validateOnParse = true; $isValid = $dom->loadHTML($html); $this->assertTrue($isValid); /* now follows a quite complex way to check if all URLs are parsable and if all * scripts that are not located on localhost are accessible. The complex thing * about this is to check scheme-relative URLs. For example //domain.de */ $URL_string = preg_replace('(.*src\\=\\"|\\".*)', "", $html); $URL_array = explode("\n", $URL_string); foreach ($URL_array as $URL) { if (!empty($URL)) { $parsed = parse_url($URL); if ($parsed === false) { $this->fail("Malformed URL: {$URL}"); continue; } if (isset($parsed['host']) && $parsed['host'] != "localhost") { if (empty($parsed['scheme'])) { $httpURL = 'http://' . ltrim($URL, '/'); $headers = @get_headers($httpURL); if (!$headers && strpos($headers[0], '200') !== false) { $httpsURL = 'https://' . ltrim($URL, '/'); $headers = @get_headers($httpsURL); } } else { $headers = @get_headers($URL); } $this->assertTrue($headers && strpos($headers[0], '200') !== false, "Script not found: {$URL}"); } } } }
/** * Konstruktor für die Application-Klasse. Hier wird die Konfiguration * eingelesen und die Provider initialisiert */ protected function __construct() { Profiler::setActive(true); try { Configuration::getInstance()->readConfig(); } catch (Exception $e) { Http::serverError('Fehler beim Lesen der Konfiguration ' . $e->getMessage()); } }
/** * @covers \NewFrontiers\Framework\Output\Mailer::sendMail * @covers \NewFrontiers\Framework\Output\Mailer::sendNotification * @covers \NewFrontiers\Framework\Output\Mailer::getInstance */ public function testSendNotification() { $this->assertSame(Mailer::getInstance(), Mailer::getInstance()); Configuration::getInstance()->readConfig(); $mailer = $this->createMailerMock($lastMail); $this->assertSame($mailer, Mailer::getInstance()); Mailer::sendNotification("test", "testnachricht"); $fromAndTo = Configuration::get('mail.from'); $this->assertContains("Subject: test", $lastMail); $this->assertContains("From: " . $fromAndTo, $lastMail); $this->assertContains("To: " . $fromAndTo, $lastMail); $this->assertContains("\ntestnachricht", $lastMail); }