-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In addition to php -l and phpcs this can discover e.g. method signature incompatibilities
- Loading branch information
Showing
2 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/php/library/Icinga/Application/PhpCodeValidityTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */ | ||
|
||
namespace Tests\Icinga\Application; | ||
|
||
use Icinga\Application\Config; | ||
use Icinga\Data\ConfigObject; | ||
use Icinga\File\Storage\TemporaryLocalFileStorage; | ||
use Icinga\Test\BaseTestCase; | ||
|
||
class PhpCodeValidityTest extends BaseTestCase | ||
{ | ||
/** | ||
* Collect all classes, interfaces and traits and let PHP validate them as if included | ||
*/ | ||
public function testAllClassesInterfacesAndTraits() | ||
{ | ||
$modDirs = array(); | ||
$modules = array(); | ||
|
||
foreach (preg_split('/:/', getenv('ICINGAWEB_MODULE_DIRS'), -1, PREG_SPLIT_NO_EMPTY) as $modDir) { | ||
$modDirs[dirname($modDir)] = null; | ||
$modules[] = basename($modDir); | ||
} | ||
|
||
$storage = new TemporaryLocalFileStorage(); | ||
|
||
$storage->create('etc/icingaweb2/config.ini', (string) new Config(new ConfigObject(array( | ||
'global' => array( | ||
'module_path' => implode(':', array_keys($modDirs)), | ||
'config_backend' => 'ini' | ||
) | ||
)))); | ||
|
||
$icingacli = 'ICINGAWEB_CONFIGDIR=' . $storage->resolvePath('etc/icingaweb2') | ||
. ' ' . realpath('/proc/self/exe') . ' ' . ( | ||
getenv('ICINGAWEB_BASEDIR') ?: realpath(__DIR__ . '/../../../../..') | ||
) . '/bin/icingacli'; | ||
|
||
foreach ($modules as $module) { | ||
$this->system("$icingacli module enable $module"); | ||
} | ||
|
||
$this->system("$icingacli test php validity"); | ||
} | ||
|
||
protected function system($command) | ||
{ | ||
echo "+ $command" . PHP_EOL; | ||
|
||
$return = 127; | ||
system($command, $return); | ||
|
||
$this->assertSame(0, $return); | ||
} | ||
} |