Example #1
0
 public function testProjectCheckEngine()
 {
     // same tests as for Simple engine - they should report the same errors
     // usage with parsed file
     $lint_engine = new XRef_LintEngine_ProjectCheck($this->xref, false);
     $pf = $this->xref->getParsedFile("fileA.php", '<?php echo $foo;');
     $lint_engine->addParsedFile($pf);
     $report = $lint_engine->collectReport();
     $this->assertTrue(count($report) == 1);
     $this->assertTrue(isset($report["fileA.php"]));
     $this->assertTrue(count($report["fileA.php"]) == 1);
     $this->assertTrue($report["fileA.php"][0]->tokenText == '$foo');
     // usage with file provider
     $lint_engine = new XRef_LintEngine_ProjectCheck($this->xref, false);
     $file_provider = new XRef_FileProvider_InMemory(array('fileA.php' => '<?php echo $bar;'));
     $report = $lint_engine->getReport($file_provider);
     $this->assertTrue(count($report) == 1);
     $this->assertTrue(isset($report["fileA.php"]));
     $this->assertTrue(count($report["fileA.php"]) == 1);
     $this->assertTrue($report["fileA.php"][0]->tokenText == '$bar');
     // only the php files are checked
     $lint_engine = new XRef_LintEngine_ProjectCheck($this->xref, false);
     $file_provider = new XRef_FileProvider_InMemory(array('fileA.php' => '<?php echo $baz;', 'fileB.txt' => 'some text with $foo', 'fileC.txt' => '<?php looks like php'));
     $report = $lint_engine->getReport($file_provider);
     $this->assertTrue(count($report) == 1);
     $this->assertTrue(isset($report["fileA.php"]));
     $this->assertTrue(count($report["fileA.php"]) == 1);
     $this->assertTrue($report["fileA.php"][0]->tokenText == '$baz');
     // but project integrity is checked now!
     // no project integrity is checked
     $lint_engine = new XRef_LintEngine_ProjectCheck($this->xref, false);
     $file_provider = new XRef_FileProvider_InMemory(array('fileA.php' => '<?php class A { const FOO = 1; }', 'fileB.php' => '<?php echo A::BAR; '));
     $report = $lint_engine->getReport($file_provider);
     $this->assertTrue(count($report) == 1);
     $this->assertTrue(isset($report["fileB.php"]));
     $this->assertTrue(count($report["fileB.php"]) == 1);
     $this->assertTrue($report["fileB.php"][0]->tokenText == 'BAR');
 }