mirror of
https://github.com/flarum/framework.git
synced 2024-11-22 11:16:39 +08:00
chore: improve test suite (#3814)
Allows running tests without constantly running `composer install` on each extension.
This commit is contained in:
parent
6bc19e2e52
commit
64b25b26c3
30
.github/workflows/REUSABLE_backend.yml
vendored
30
.github/workflows/REUSABLE_backend.yml
vendored
|
@ -21,6 +21,12 @@ on:
|
|||
required: false
|
||||
default: '.'
|
||||
|
||||
# Only relevant in mono-repos.
|
||||
monorepo_tests:
|
||||
description: "The list of directories to test in a monorepo. This should be a space-separated list of directories relative to the backend directory."
|
||||
type: string
|
||||
required: false
|
||||
|
||||
php_versions:
|
||||
description: Versions of PHP to test with. Should be array of strings encoded as JSON array
|
||||
type: string
|
||||
|
@ -47,6 +53,7 @@ on:
|
|||
|
||||
env:
|
||||
COMPOSER_ROOT_VERSION: dev-main
|
||||
# `inputs.composer_directory` defaults to `inputs.backend_directory`
|
||||
FLARUM_TEST_TMP_DIR_LOCAL: tests/integration/tmp
|
||||
|
||||
jobs:
|
||||
|
@ -143,18 +150,27 @@ jobs:
|
|||
run: composer install
|
||||
working-directory: ${{ inputs.backend_directory }}
|
||||
|
||||
- name: Setup Composer tests
|
||||
run: composer test:setup
|
||||
# If we have a `inputs.monorepo_tests`, we will run tests for each item of the provided array in a ::group::item
|
||||
# If we don't have a `inputs.monorepo_tests`, we will run tests for the current repository
|
||||
# We also have to run the `composer test:setup` script first before running each test
|
||||
- name: Run tests
|
||||
run: |
|
||||
if [ -z "${{ inputs.monorepo_tests }}" ]; then
|
||||
composer test:setup
|
||||
composer test
|
||||
else
|
||||
for test in ${{ inputs.monorepo_tests }}; do
|
||||
echo "::group::Running tests for $test"
|
||||
composer test:setup --working-dir=$test
|
||||
composer test --working-dir=$test
|
||||
echo "::endgroup::"
|
||||
done
|
||||
fi
|
||||
working-directory: ${{ inputs.backend_directory }}
|
||||
env:
|
||||
DB_PORT: 13306
|
||||
DB_PASSWORD: root
|
||||
DB_PREFIX: ${{ matrix.prefix }}
|
||||
|
||||
- name: Run Composer tests
|
||||
run: composer test
|
||||
working-directory: ${{ inputs.backend_directory }}
|
||||
env:
|
||||
COMPOSER_PROCESS_TIMEOUT: 600
|
||||
|
||||
phpstan:
|
||||
|
|
11
.github/workflows/backend.yml
vendored
Normal file
11
.github/workflows/backend.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
name: Backend Tests
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
backend_directory: .
|
||||
monorepo_tests: "framework/core extensions/akismet extensions/approval extensions/flags extensions/likes extensions/mentions extensions/nicknames extensions/statistics extensions/sticky extensions/subscriptions extensions/suspend extensions/tags"
|
11
.github/workflows/flarum-akismet-backend.yml
vendored
11
.github/workflows/flarum-akismet-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Akismet PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/akismet
|
11
.github/workflows/flarum-approval-backend.yml
vendored
11
.github/workflows/flarum-approval-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Approval PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/approval
|
11
.github/workflows/flarum-core-backend.yml
vendored
11
.github/workflows/flarum-core-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Core PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./framework/core
|
11
.github/workflows/flarum-embed-backend.yml
vendored
11
.github/workflows/flarum-embed-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Embed PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/embed
|
11
.github/workflows/flarum-emoji-backend.yml
vendored
11
.github/workflows/flarum-emoji-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Emoji PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/emoji
|
11
.github/workflows/flarum-flags-backend.yml
vendored
11
.github/workflows/flarum-flags-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Flags PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/flags
|
11
.github/workflows/flarum-likes-backend.yml
vendored
11
.github/workflows/flarum-likes-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Likes PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/likes
|
11
.github/workflows/flarum-lock-backend.yml
vendored
11
.github/workflows/flarum-lock-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Lock PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/lock
|
11
.github/workflows/flarum-markdown-backend.yml
vendored
11
.github/workflows/flarum-markdown-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Markdown PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/markdown
|
11
.github/workflows/flarum-mentions-backend.yml
vendored
11
.github/workflows/flarum-mentions-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Mentions PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/mentions
|
11
.github/workflows/flarum-nicknames-backend.yml
vendored
11
.github/workflows/flarum-nicknames-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Nicknames PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/nicknames
|
|
@ -1,11 +0,0 @@
|
|||
name: Package Manager PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/package-manager
|
11
.github/workflows/flarum-pusher-backend.yml
vendored
11
.github/workflows/flarum-pusher-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Pusher PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: false
|
||||
|
||||
backend_directory: ./extensions/pusher
|
11
.github/workflows/flarum-statistics-backend.yml
vendored
11
.github/workflows/flarum-statistics-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Statistics PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/statistics
|
11
.github/workflows/flarum-sticky-backend.yml
vendored
11
.github/workflows/flarum-sticky-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Sticky PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/sticky
|
|
@ -1,11 +0,0 @@
|
|||
name: Subscriptions PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/subscriptions
|
11
.github/workflows/flarum-suspend-backend.yml
vendored
11
.github/workflows/flarum-suspend-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Suspend PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/suspend
|
11
.github/workflows/flarum-tags-backend.yml
vendored
11
.github/workflows/flarum-tags-backend.yml
vendored
|
@ -1,11 +0,0 @@
|
|||
name: Tags PHP
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
jobs:
|
||||
run:
|
||||
uses: ./.github/workflows/REUSABLE_backend.yml
|
||||
with:
|
||||
enable_backend_testing: true
|
||||
|
||||
backend_directory: ./extensions/tags
|
2
.github/workflows/frontend.yml
vendored
2
.github/workflows/frontend.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Framework JS
|
||||
name: Frontend Workflow
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
|
|
3
.github/workflows/phpstan.yml
vendored
3
.github/workflows/phpstan.yml
vendored
|
@ -1,4 +1,4 @@
|
|||
name: Framework PHP
|
||||
name: Static Code Analysis
|
||||
|
||||
on: [workflow_dispatch, push, pull_request]
|
||||
|
||||
|
@ -8,5 +8,4 @@ jobs:
|
|||
with:
|
||||
enable_backend_testing: false
|
||||
enable_phpstan: true
|
||||
|
||||
backend_directory: .
|
||||
|
|
|
@ -60,6 +60,26 @@
|
|||
"framework/core/src/helpers.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Flarum\\Tests\\": "tests",
|
||||
"Flarum\\Akismet\\Tests\\": "extensions/akismet/tests",
|
||||
"Flarum\\Approval\\Tests\\": "extensions/approval/tests",
|
||||
"Flarum\\Flags\\Tests\\": "extensions/flags/tests",
|
||||
"Flarum\\Likes\\Tests\\": "extensions/likes/tests",
|
||||
"Flarum\\Lock\\Tests\\": "extensions/lock/tests",
|
||||
"Flarum\\Mentions\\Tests\\": "extensions/mentions/tests",
|
||||
"Flarum\\Nicknames\\Tests\\": "extensions/nicknames/tests",
|
||||
"Flarum\\PackageManager\\Tests\\": "extensions/package-manager/tests",
|
||||
"Flarum\\Pusher\\Tests\\": "extensions/pusher/tests",
|
||||
"Flarum\\Statistics\\Tests\\": "extensions/statistics/tests",
|
||||
"Flarum\\Sticky\\Tests\\": "extensions/sticky/tests",
|
||||
"Flarum\\Subscriptions\\Tests\\": "extensions/subscriptions/tests",
|
||||
"Flarum\\Suspend\\Tests\\": "extensions/suspend/tests",
|
||||
"Flarum\\Tags\\Tests\\": "extensions/tags/tests",
|
||||
"Flarum\\Testing\\Tests\\": "php-packages/testing/tests"
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"flarum/core": "self.version",
|
||||
"flarum/akismet": "self.version",
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -8,11 +8,8 @@
|
|||
*/
|
||||
|
||||
use Flarum\PackageManager\Tests\integration\SetupComposer;
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -73,31 +73,18 @@ class ExtensionManager
|
|||
$composerJsonConfs[$packagePath] = $package;
|
||||
}
|
||||
|
||||
if ($subextPaths = Arr::get($package, 'extra.flarum-subextensions', [])) {
|
||||
foreach ($subextPaths as $subExtPath) {
|
||||
$subPackagePath = "$packagePath/$subExtPath";
|
||||
$conf = json_decode($this->filesystem->get("$subPackagePath/composer.json"), true);
|
||||
|
||||
if (Arr::get($conf, 'type') === 'flarum-extension') {
|
||||
$composerJsonConfs[$subPackagePath] = $conf;
|
||||
}
|
||||
}
|
||||
if ($subExtConfs = $this->subExtensionConfsFromJson($package, $packagePath)) {
|
||||
$composerJsonConfs = array_merge($composerJsonConfs, $subExtConfs);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($composerJsonConfs as $path => $package) {
|
||||
$installedSet[Arr::get($package, 'name')] = true;
|
||||
|
||||
// Instantiates an Extension object using the package path and composer.json file.
|
||||
$extension = new Extension($path, $package);
|
||||
|
||||
// Per default all extensions are installed if they are registered in composer.
|
||||
$extension->setInstalled(true);
|
||||
$extension->setVersion(Arr::get($package, 'version'));
|
||||
|
||||
$extension = $this->extensionFromJson($package, $path);
|
||||
$extensions->put($extension->getId(), $extension);
|
||||
}
|
||||
|
||||
/** @var Extension $extension */
|
||||
foreach ($extensions as $extension) {
|
||||
$extension->calculateDependencies($installedSet);
|
||||
}
|
||||
|
@ -472,4 +459,36 @@ class ExtensionManager
|
|||
'circularDependencies' => $circularDependencies
|
||||
];
|
||||
}
|
||||
|
||||
protected function extensionFromJson(array $package, string $path): Extension
|
||||
{
|
||||
// Instantiates an Extension object using the package path and composer.json file.
|
||||
$extension = new Extension($path, $package);
|
||||
|
||||
// Per default all extensions are installed if they are registered in composer.
|
||||
$extension->setInstalled(true);
|
||||
$extension->setVersion(Arr::get($package, 'version', '0.0'));
|
||||
|
||||
return $extension;
|
||||
}
|
||||
|
||||
protected function subExtensionConfsFromJson(array $package, string $packagePath): ?array
|
||||
{
|
||||
if (! ($subExtPaths = Arr::get($package, 'extra.flarum-subextensions', []))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$subExtConfs = [];
|
||||
|
||||
foreach ($subExtPaths as $subExtPath) {
|
||||
$subPackagePath = "$packagePath/$subExtPath";
|
||||
$conf = json_decode($this->filesystem->get("$subPackagePath/composer.json"), true);
|
||||
|
||||
if (Arr::get($conf, 'type') === 'flarum-extension') {
|
||||
$subExtConfs[$subPackagePath] = $conf;
|
||||
}
|
||||
}
|
||||
|
||||
return $subExtConfs;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
42
php-packages/testing/bootstrap/monorepo.php
Normal file
42
php-packages/testing/bootstrap/monorepo.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?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();
|
|
@ -54,21 +54,11 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
|||
$extensions = parent::getExtensions();
|
||||
|
||||
$package = json_decode($this->filesystem->get($this->paths->vendor.'/../composer.json'), true);
|
||||
$packagePath = $this->paths->vendor.'/../';
|
||||
|
||||
if (Arr::get($package, 'type') === 'flarum-extension') {
|
||||
$current = new Extension($this->paths->vendor.'/../', $package);
|
||||
$current->setInstalled(true);
|
||||
$current->setVersion(Arr::get($package, 'version', '0.0'));
|
||||
$current->calculateDependencies([]);
|
||||
$extensions = $this->includeCurrentExtension($extensions, $package, $packagePath);
|
||||
|
||||
$extensions->put($current->getId(), $current);
|
||||
|
||||
$this->extensions = $extensions->sortBy(function ($extension) {
|
||||
return $extension->composerJsonAttribute('extra.flarum-extension.title');
|
||||
});
|
||||
}
|
||||
|
||||
return $this->extensions;
|
||||
return $this->extensions = $this->includeMonorepoExtensions($extensions, $package, $packagePath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,4 +101,36 @@ class ExtensionManagerIncludeCurrent extends ExtensionManager
|
|||
|
||||
return new FilesystemAdapter(new \League\Flysystem\Filesystem($adapter), $adapter);
|
||||
}
|
||||
|
||||
protected function includeCurrentExtension(Collection $extensions, $package, string $packagePath): Collection
|
||||
{
|
||||
if (Arr::get($package, 'type') === 'flarum-extension') {
|
||||
$current = new Extension($packagePath, $package);
|
||||
$current->setInstalled(true);
|
||||
$current->setVersion(Arr::get($package, 'version', '0.0'));
|
||||
$current->calculateDependencies([]);
|
||||
|
||||
$extensions->put($current->getId(), $current);
|
||||
|
||||
$extensions = $extensions->sortBy(function ($extension, $name) {
|
||||
return $extension->composerJsonAttribute('extra.flarum-extension.title');
|
||||
});
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows symlinking the vendor directory in extensions when running tests on monorepos.
|
||||
*/
|
||||
protected function includeMonorepoExtensions(Collection $extensions, $package, string $packagePath): Collection
|
||||
{
|
||||
foreach ($this->subExtensionConfsFromJson($package, $packagePath) ?? [] as $path => $package) {
|
||||
$extension = $this->extensionFromJson($package, $path);
|
||||
$extension->calculateDependencies([]);
|
||||
$extensions->put($extension->getId(), $extension);
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ class SetupScript
|
|||
'base' => $tmp,
|
||||
'public' => "$tmp/public",
|
||||
'storage' => "$tmp/storage",
|
||||
'vendor' => getcwd().'/vendor',
|
||||
'vendor' => getenv('FLARUM_TEST_VENDOR_PATH') ?: getcwd().'/vendor',
|
||||
])
|
||||
);
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
|
|||
'base' => $tmp,
|
||||
'public' => "$tmp/public",
|
||||
'storage' => "$tmp/storage",
|
||||
'vendor' => getcwd().'/vendor',
|
||||
'vendor' => getenv('FLARUM_TEST_VENDOR_PATH') ?: getcwd().'/vendor',
|
||||
]),
|
||||
new Config($config)
|
||||
);
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Flarum\Testing\integration\Setup\SetupScript;
|
||||
|
||||
require __DIR__.'/../../vendor/autoload.php';
|
||||
|
||||
$setup = new SetupScript();
|
||||
$setup = require __DIR__.'/../../../../php-packages/testing/bootstrap/monorepo.php';
|
||||
|
||||
$setup->run();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="true"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
bootstrap="../../../php-packages/testing/bootstrap/monorepo.php"
|
||||
>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
|
|
Loading…
Reference in New Issue
Block a user