FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
startUpTest.php
1 <?php
2 /*
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 version 2 as published by the Free Software Foundation.
6 
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
11 
12 You should have received a copy of the GNU General Public License along
13 with this program; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15 */
16 
17 class StartUpTest extends \PHPUnit\Framework\TestCase
18 {
20  private $pageContent;
21 
22  protected function setUp()
23  {
24  $this->pageContent = '';
25  $p = popen('php '. dirname(__DIR__).'/ui/index.php 2>&1', 'r');
26  while (!feof($p)) {
27  $line = fgets($p, 1000);
28  $this->pageContent .= $line;
29  }
30  pclose($p);
31  }
32 
33  private function assertCriticalStringNotfound($critical) {
34  $criticalPos = strpos($this->pageContent, $critical);
35  $criticalEnd = $criticalPos===false ? $criticalPos : strpos($this->pageContent, "\n", $criticalPos);
36  $this->assertTrue(false===$criticalPos, "There was a $critical at position $criticalPos:\n". substr($this->pageContent, $criticalPos, $criticalEnd-$criticalPos)."\n");
37  }
38 
39  public function testIsHtmlAndNoWarningFound()
40  {
41  assertThat($this->pageContent, startsWith('<!DOCTYPE html>'));
42  $this->assertCriticalStringNotfound('PHP Notice');
43  $this->assertCriticalStringNotfound('PHP Fatal error');
44  $this->assertCriticalStringNotfound('PHP Warning');
45  }
46 
47 }