Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoloader to verify_phpunit_xml #301

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tests/verify_phpunit_xml.bats
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ teardown () {
last_test || store_workspace
}

@test "verify_phpunit_xml: normal run without errors" {
@test "verify_phpunit_xml: normal run without errors (old branch)" {
ci_run verify_phpunit_xml/verify_phpunit_xml.sh

assert_success
Expand All @@ -24,6 +24,19 @@ teardown () {
refute_output --partial "ERROR"
}

@test "verify_phpunit_xml: normal run without errors and warnings (main branch)" {
create_git_branch main origin/main

ci_run verify_phpunit_xml/verify_phpunit_xml.sh

assert_success
assert_output --partial "OK: competency/tests will be executed"
assert_output --partial "INFO: backup/util/ui/tests will be executed because the backup/util definition"
assert_output --partial "INFO: Ignoring privacy/classes/tests, it does not contain any test unit file."
refute_output --partial "WARNING"
refute_output --partial "ERROR"
}

@test "verify_phpunit_xml: test detected into not covered by suite directory" {
git_apply_fixture verify_phpunit_xml/add_uncovered_test.patch

Expand Down
4 changes: 4 additions & 0 deletions verify_phpunit_xml/create_phpunit_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
cli_error('Something went wrong. Components not loaded from ' . $options['basedir']);
}

// We need to register the Moodle autoloader.
require_once($options['basedir'] . '/lib/classes/component.php');
spl_autoload_register([\core_component::class, 'classloader']);

// Now, let's invoke phpunit utils to generate the phpunit.xml file

// We need to load a few stuff.
Expand Down