-
Notifications
You must be signed in to change notification settings - Fork 21
Add code testing via phpunit and/or cypress #167
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
base: master
Are you sure you want to change the base?
Conversation
…able two joomla extensions that could cause issues in tests
|
Hello it seems to be a big work. |
|
For phpunit:
For cypress:
|
|
@parapente for phpunit I have an error at st step 1) |
|
I fixed last error by adding link from temp\joomla\libraries\src to joomla 4.x library src path |
|
Next error is |
|
@JLTRY yes that is the error I'm getting too. The summary gives: but most of those that pass as quite trivial tests. Another thing that will be of importance if we continue to work with phpunit is that the joomla framework packages have different numbering from the joomla cms releases:
So for the packages that I have added as requirements in composer.json we should use the joomla 6 code in /temp/joomla. |
|
I have made a link to joomla_6 libraries/src. It still fails I have got this error |
Do you run cypress under windows /docker or under linux / docker ? |
|
I am using linux / docker but using docker should give you the same result both on linux and windows. On windows is a little more complicated to get started with docker and a little less performant but it should be the same. There is another way to run the cypress tests but it will require you to do some manual configuration. Instead of running Cypress has two modes of running: headless (which just runs the tests and doesn't open an application window) and desktop. For now I am using the desktop mode to write the tests and when they are ready, using the same config we could add a github action to run the tests automatically on every push we make to the repository. |
|
@parapente I was able to launch at least one test JoomlasReady |
|
docker desktop on windows uses wsl which has the tendency of halfing your pc's memory even if wsl does nothing (half for windows, half for wsl). If your pc has only 8gb of ram things will be extra tight. See if the solution found here helps: https://www.reddit.com/r/docker/comments/135p45t/wsl_using_way_too_much_ram/ I will change the tests slightly as the tests right now empty the database at each run which is not recommended. That will probably fix the issue you have right now as it seems to fail to empty the database. |
|
@JLTRY I managed to make the tests run correctly: I am not 100% happy with the state of the code but it at least works. I will review the code on the weekend to untangle the mess I created just to make it work. Joomla has many interconnected parts that makes it difficult to run such tests without running a web server & database. Feel free to test on your end for any issues. |
|
@parapente Any advice ? |
|
@JLTRY You need to install the php sqlite extension to be able to run the tests. By the way I forgot to mention that there are some data missing from the repository that were used to initialize some tables with data. They are not really necessary but this is the reason you will see some hard coded values in the code. I will need to extract those values in a seperate structure. |
|
Runtime: PHP 8.3.3 ..........WW.WWWWWWWWW......................................... 63 / 222 ( 28%) Time: 00:03.729, Memory: 16.00 MB OK, but there were issues! |
|
@parapente To be noticed that we can tell phpunit to be more verbose by setting
Triggered by:
|
|
I did check the warnings/deprecations using the switches --display-warnings and --display-deprecations but the ones that are left don't really matter much. They are not in our code but due to the way the code is running some joomla function fails to return an array and that is why we get the warning/deprecation. While refactoring the test code I will revisit the warning in case I can make the test skip this joomla plugin function. |
|
@JLTRY I tried to rebuild the |
|
I checked the unit tests and it is OK for me |
This is an effort to add automated testing of the code to ensure that the extension works whenever new patches are added to the codebase or the joomla framework changes.
There are few phpunit tests (ported from older tests that were present in the codebase) but almost all fail for now. It will need quite some effort to refactor the extension code to be able to test it effectivly using phpunit.
Cypress on the other hand can help us test the extension as it is running on an joomla instance like we would manually. I started adding some basic tests that are run in batches. I have created folders for each part of the package in /cypress/e2e that eventually will be populated with the tests.
I will add a checklist for everything that needs to be done and of course the last step would be to add github actions to run the tests whenever we push code to master.