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

Unit test class collision with qtype_stack #788

Open
Fragonite opened this issue Jan 10, 2025 · 0 comments
Open

Unit test class collision with qtype_stack #788

Fragonite opened this issue Jan 10, 2025 · 0 comments

Comments

@Fragonite
Copy link

This plugin defines a Response class in the global namespace, causing a class collision and failing unit tests when qtype_stack creates a mock class with the same name.

Using namespaces would have prevented this issue. Are there any plans for introducing them?

https://github.com/turnitin/moodle-mod_turnitintooltwo/blob/develop/sdk/response.class.php#L11

https://github.com/maths/moodle-qtype_stack/blob/master/tests/api_controller_test.php#L103-L106

Example test output below. Tested with Moodle 4.1 and 4.5.

1) qtype_stack\api_controller_test::test_render
PHPUnit\Framework\MockObject\ClassAlreadyExistsException: Class "Response" already exists

/var/www/muat/question/type/stack/tests/api_controller_test.php:124
/var/www/muat/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/muat/vendor/phpunit/phpunit/phpunit:97

2) qtype_stack\api_controller_test::test_render_specified_seed
PHPUnit\Framework\MockObject\ClassAlreadyExistsException: Class "Response" already exists

/var/www/muat/question/type/stack/tests/api_controller_test.php:124
/var/www/muat/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/muat/vendor/phpunit/phpunit/phpunit:97

3) qtype_stack\api_controller_test::test_render_plots
PHPUnit\Framework\MockObject\ClassAlreadyExistsException: Class "Response" already exists

/var/www/muat/question/type/stack/tests/api_controller_test.php:124
/var/www/muat/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/muat/vendor/phpunit/phpunit/phpunit:97

4) qtype_stack\api_controller_test::test_render_iframes
PHPUnit\Framework\MockObject\ClassAlreadyExistsException: Class "Response" already exists

/var/www/muat/question/type/stack/tests/api_controller_test.php:124
/var/www/muat/lib/phpunit/classes/advanced_testcase.php:80
phpvfscomposer:///var/www/muat/vendor/phpunit/phpunit/phpunit:97

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant