-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify all required files explicitly in given order and test all lib…
…s loaded (#213) Alphabetical order, coincidentally. Partially reverts #204 commit 6bf2f2b Close #211
- Loading branch information
Showing
2 changed files
with
43 additions
and
8 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Spaze\PHPStan\Rules\Disallowed; | ||
|
||
use FilesystemIterator; | ||
use PHPStan\Testing\PHPStanTestCase; | ||
use RecursiveDirectoryIterator; | ||
use RecursiveIteratorIterator; | ||
|
||
class BootstrapTest extends PHPStanTestCase | ||
{ | ||
|
||
public function testBootstrapRequiresAllLibs(): void | ||
{ | ||
$allRequired = get_required_files(); | ||
$notRequired = []; | ||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/libs', FilesystemIterator::SKIP_DOTS)); | ||
foreach ($iterator as $fileInfo) { | ||
if ($fileInfo->getExtension() === 'php') { | ||
if (!in_array($this->getFileHelper()->normalizePath($fileInfo->getPathname()), $allRequired)) { | ||
$notRequired[] = $fileInfo->getPathname(); | ||
} | ||
} | ||
} | ||
$this->assertEmpty($notRequired, 'Require these files in bootstrap.php: ' . implode(', ', $notRequired)); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/libs', FilesystemIterator::SKIP_DOTS)); | ||
foreach ($iterator as $fileInfo) { | ||
if ($fileInfo->getExtension() === 'php') { | ||
require_once $fileInfo->getPathname(); | ||
} | ||
} | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
require __DIR__ . '/libs/AttributeClass.php'; | ||
require __DIR__ . '/libs/AttributeEntity.php'; | ||
require __DIR__ . '/libs/Bar.php'; | ||
require __DIR__ . '/libs/Blade.php'; | ||
require __DIR__ . '/libs/Constructor.php'; | ||
require __DIR__ . '/libs/Functions.php'; | ||
require __DIR__ . '/libs/Inheritance.php'; | ||
require __DIR__ . '/libs/Option.php'; | ||
require __DIR__ . '/libs/Royale.php'; | ||
require __DIR__ . '/libs/SomeInterface.php'; | ||
require __DIR__ . '/libs/TestException.php'; | ||
require __DIR__ . '/libs/TestTrait.php'; | ||
require __DIR__ . '/libs/Traits.php'; |