Skip to content

Commit

Permalink
test: standardize the autoload usage (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored May 13, 2024
1 parent c1e866e commit ccf574d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 27 deletions.
4 changes: 3 additions & 1 deletion fixtures/set016-symfony-finder/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

require_once __DIR__ . '/vendor/autoload.php';
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

$finder = Finder::create()->files()->in(__DIR__)->depth(0)->sortByName();

Expand Down
4 changes: 3 additions & 1 deletion fixtures/set017-symfony-di/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

require_once __DIR__ . '/vendor/autoload.php';
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

interface Salute
{
Expand Down
4 changes: 3 additions & 1 deletion fixtures/set018-nikic-parser/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use PhpParser\NodeDumper;
use PhpParser\ParserFactory;

require_once __DIR__ . '/vendor/autoload.php';
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

$code = <<<'CODE'
<?php
Expand Down
8 changes: 3 additions & 5 deletions fixtures/set024/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

use function file_exists;

if (file_exists($autoload = __DIR__ . '/vendor/scoper-autoload.php')) {
require_once $autoload;
} else {
require_once __DIR__ . '/vendor/autoload.php';
}
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

dump('foo', 'bar');
8 changes: 3 additions & 5 deletions fixtures/set025/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
use function file_exists;
use function iter\toArray;

if (file_exists($autoload = __DIR__ . '/vendor/scoper-autoload.php')) {
require_once $autoload;
} else {
require_once __DIR__ . '/vendor/autoload.php';
}
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

// Use concatenation to ensure it does not prefix this call. This allows to
// double check that exposing this function works correctly.
Expand Down
10 changes: 3 additions & 7 deletions fixtures/set029-easy-rdf/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

declare(strict_types=1);

$autoload = __DIR__.'/vendor/scoper-autoload.php';

if (false === file_exists($autoload)) {
$autoload = __DIR__.'/vendor/autoload.php';
}

require_once $autoload;
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

$foaf = new EasyRdf\Graph('http://njh.me/foaf.rdf');
$count = $foaf->load();
Expand Down
10 changes: 3 additions & 7 deletions fixtures/set030/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

declare(strict_types=1);

$autoload = __DIR__.'/vendor/scoper-autoload.php';

if (false === file_exists($autoload)) {
$autoload = __DIR__.'/vendor/autoload.php';
}

require_once $autoload;
require file_exists(__DIR__.'/vendor/scoper-autoload.php')
? __DIR__.'/vendor/scoper-autoload.php'
: __DIR__.'/vendor/autoload.php';

echo foo() ? 'ok' : 'ko';
echo PHP_EOL;
Expand Down

0 comments on commit ccf574d

Please sign in to comment.