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

issue #97: Import externallib with use statements #120

Merged

Conversation

ScottVerbeek
Copy link
Contributor

Resolves coding_exception in MOODLE_402_STABLE and up.

These tests were executed on a 4.3+ branch:

vendor/bin/phpunit --testsuite=search_elastic_testsuite
Moodle 4.3+ (Build: 20231027), e57253711b64132738b2496e6bbfc8ebb02bbb3d
Php: 8.1.24, pgsql: 14.0 (Debian 14.0-1.pgdg110+1), OS: Linux 6.4.12-060412-generic x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

...............................................................  63 / 110 ( 57%)
...............................................                 110 / 110 (100%)

Time: 01:13.444, Memory: 95.50 MB

OK (110 tests, 217 assertions)

Closes #97

@ScottVerbeek ScottVerbeek force-pushed the issue-97-resolve-unit-tests-for-moodle-402 branch 3 times, most recently from b6ea12e to b7f1674 Compare December 28, 2023 05:11
@ScottVerbeek
Copy link
Contributor Author

ScottVerbeek commented Dec 28, 2023

The tests performed earlier on this unit test were not on the most recent version of Moodle 4.3. I have now updated locally and amended the commit resolving one of two problems. I'm still looking into this failing unit test.

vendor/bin/phpunit --testsuite search_elastic_testsuite
Moodle 4.3.2 (Build: 20231222), f810374a0ec816eca849f807cb09ff0c478438b7
Php: 8.1.24, pgsql: 14.0 (Debian 14.0-1.pgdg110+1), OS: Linux 6.4.12-060412-generic x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

.....................................F.........................  63 / 115 ( 54%)
....................................................            115 / 115 (100%)

Time: 01:22.411, Memory: 80.50 MB

There was 1 failure:

1) search_elastic\esrequest_test::test_get_unreachable_host
Failed asserting that exception of type "GuzzleHttp\Exception\ConnectException" is thrown.

/var/www/vanilla-403/lib/phpunit/classes/advanced_testcase.php:81

FAILURES!
Tests: 115, Assertions: 223, Failures: 1.

@ScottVerbeek ScottVerbeek marked this pull request as draft December 28, 2023 22:34
@ScottVerbeek
Copy link
Contributor Author

There was 1 failure:

1) search_elastic\esrequest_test::test_get_unreachable_host
Failed asserting that exception of type "GuzzleHttp\Exception\ConnectException" is thrown.

/var/www/vanilla-403/lib/phpunit/classes/advanced_testcase.php:81

This failure has been relation to my local environment. I have setup a simpler one and the tests are now all passing. This MR is ready for a review.

@ScottVerbeek ScottVerbeek marked this pull request as ready for review January 1, 2024 22:48
@ScottVerbeek
Copy link
Contributor Author

Due to https://tracker.moodle.org/browse/MDL-76583 this will need a separate branch. I'll create MOODLE_402_STABLE and update the readme.

Resolves coding_exception in MOODLE_402_STABLE and up.
@ScottVerbeek ScottVerbeek force-pushed the issue-97-resolve-unit-tests-for-moodle-402 branch from b7f1674 to 234c438 Compare January 2, 2024 01:44
@ScottVerbeek ScottVerbeek changed the base branch from MOODLE_310_STABLE to MOODLE_402_STABLE January 2, 2024 01:45
@ScottVerbeek
Copy link
Contributor Author

Once this has been mered, I'll create merge requests into the other branches updating the readme. Once those have been merged I'll make the branch MOODLE_402_STABLE the new default branch.

Copy link
Contributor

@keevan keevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional changes here look okay.

In addition to the notes, are you able to check the CI, there seems to be some errors.

@@ -2,18 +2,18 @@
# Whenever version.php is changed, add the latest version
# to the Moodle Plugins directory at https://moodle.org/plugins
#
name: MOODLE_310_STABLE - Releasing in the Plugins directory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth combining the release logic into ci.yml (per the latest reusable workflows docs)

@@ -17,6 +17,7 @@ This plugin currently supports Moodle:

| Moodle version | Branch |
| ------------------- | -------------------- |
| Moodle 4.2 and up | MOODLE_402_STABLE |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are 4.0 and 4.1 not supported, if they are, which branch should be used? Seems to be a gap here.

Could you check this please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to https://tracker.moodle.org/browse/MDL-76583 Moodle 4.0 and 4.1 are not supported. I have amended the readme commit accordingly. Even though the commit introduces the namespace I have also given this a test locally. Here are the results of that.

PHPUnit tests results with changes on Moodle 4.1.8 (Build: 20231222)
root@b0ba46b747f2:/var/www/site# vendor/bin/phpunit --testsuite search_elastic_testsuite
Moodle 4.1.8 (Build: 20231222), e591ddc4e8c21df9fb5369e388ef57ef07acbb9b
Php: 8.1.24, pgsql: 14.0 (Debian 14.0-1.pgdg110+1), OS: Linux 6.4.12-060412-generic x86_64
PHPUnit 9.5.28 by Sebastian Bergmann and contributors.

...............................................EE..............  63 / 115 ( 54%)
....................................................            115 / 115 (100%)

Time: 02:21.574, Memory: 78.50 MB

There were 2 errors:

1) search_elastic\externallib_test::test_external_search
Error: Class "core_external\external_api" not found

/var/www/site/search/engine/elastic/externallib.php:40
/var/www/site/search/engine/elastic/tests/externallib_test.php:103
/var/www/site/lib/phpunit/classes/advanced_testcase.php:80

2) search_elastic\externallib_test::test_external_search_areas
Error: Class "search_elastic_external" not found

/var/www/site/search/engine/elastic/tests/externallib_test.php:172
/var/www/site/lib/phpunit/classes/advanced_testcase.php:80

ERRORS!
Tests: 115, Assertions: 219, Errors: 2.

@ScottVerbeek ScottVerbeek force-pushed the issue-97-resolve-unit-tests-for-moodle-402 branch from 75dcbe3 to c71c371 Compare January 5, 2024 04:10
@ScottVerbeek ScottVerbeek force-pushed the issue-97-resolve-unit-tests-for-moodle-402 branch from c71c371 to e4435ae Compare January 5, 2024 04:49
Copy link
Contributor

@keevan keevan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks Scott.

@ScottVerbeek ScottVerbeek merged commit 188b02d into MOODLE_402_STABLE Jan 5, 2024
7 of 15 checks passed
This was referenced Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP Fatal error runinseparate process
2 participants