framework/php-packages/testing/bootstrap/monorepo.php
Sami Mazouz 64b25b26c3
chore: improve test suite (#3814)
Allows running tests without constantly running `composer install` on each extension.
2023-06-15 13:26:39 +01:00

43 lines
1.2 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
/*
|
| This is specific to a monorepo setup. If you're using a single
| repository for your extension, checkout the extension skeleton
| at https://github.com/flarum/cli/tree/main/boilerplate/skeleton/extension.
|
| ---------------------------------------------------------------
|
| We symlink local vendor bins to the framework vendor bin
| to be able to run scripts from the extension directory.
|
| We also use a `FLARUM_TEST_VENDOR_PATH` environment variable
| to tell each extension where to find the framework vendor,
| instead of a SetupScript property, because it is also needed
| when running the tests.
|
*/
$monorepoVendor = __DIR__.'/../../../vendor';
// The root directory of the extension where tests are run from.
$localVendor = getcwd().'/vendor';
if (! file_exists("$localVendor/bin")) {
mkdir("$localVendor");
symlink("$monorepoVendor/bin", "$localVendor/bin");
}
require $monorepoVendor.'/autoload.php';
putenv('FLARUM_TEST_VENDOR_PATH='.$monorepoVendor);
return new Flarum\Testing\integration\Setup\SetupScript();