Skip to content

Feature/unit tests#79

Merged
nuest merged 47 commits into
codecheckers:mainfrom
dxL1nus:feature/unit-tests
Apr 10, 2026
Merged

Feature/unit tests#79
nuest merged 47 commits into
codecheckers:mainfrom
dxL1nus:feature/unit-tests

Conversation

@dxL1nus

@dxL1nus dxL1nus commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

closes #70
closes #40
closes #73
closes codecheckers/check-pub#35
closes #96

!IMPORTANT: This PR can only be safely merged after PR #63

This is the PR for the first unit tests for the ojs-codecheck plugin. The tests are mainly for the RetrieveReserveIdentifiers scripts and can act as a guideline/ template on how to write other unit tests for the remaining class files.

Run the tests with the following command from the PKP OJS root directory:

lib/pkp/lib/vendor/phpunit/phpunit/phpunit -c lib/pkp/tests/phpunit.xml plugins/generic/codecheck/tests/

Results:
grafik

find the test coverage in the following file:

/var/www/html/ojs-tests/lib/pkp/tests/results/index.html
grafik

@dxL1nus dxL1nus requested a review from nuest December 18, 2025 18:17
@dxL1nus dxL1nus self-assigned this Dec 18, 2025
@nuest

nuest commented Jan 19, 2026

Copy link
Copy Markdown
Member

@Subhanaliweb will include these changes in his upcoming PR with a full test suite.

- Add PHP unit tests for all classes (212 tests)
  * Constants, Submission, Settings, Workflow, Frontend, Migration
  * CodecheckPlugin with comprehensive hook testing
  * 185 tests pass locally, 27 skipped (require full OJS environment)

- Add Cypress component tests (51 tests - all passing)
  * CodecheckManifestFiles (6 tests)
  * CodecheckMetadataForm (20 tests)
  * CodecheckRepositoryList (6 tests)
  * CodecheckReviewDisplay (7 tests)
  * CodecheckCertificateIdentifier (6 tests)
  * CodecheckDataAndSoftwareAvailability (6 tests)

- Add test infrastructure
  * PHPUnit: bootstrap.php, PKPTestCase.php, phpunit.xml
  * Cypress: cypress.config.js, pkp-mock.js, component support files
  * GitHub Actions workflow for automated component testing

- Update README with testing documentation
  * Local testing instructions
  * Docker/CI testing instructions
  * Component testing commands

Total: 263 tests (212 PHP + 51 component)
@subhanLabs

Copy link
Copy Markdown
Member

As discussed, I pulled this branch and applied my testing on top of the commits he made.

@nuest

nuest commented Jan 29, 2026

Copy link
Copy Markdown
Member

As discussed, I pulled this branch and applied my testing on top of the commits he made.

@Subhanaliweb Can you briefly confirm: 1. we can close this PR unmerged. 2. You will open a new PR with your combined test suites.

@subhanLabs

Copy link
Copy Markdown
Member

I have appleid my commits of all other testing on this branch so we can merge this one, my other branches will no longer be needed.

@nuest

nuest commented Jan 30, 2026

Copy link
Copy Markdown
Member

Thanks for the clarification @Subhanaliweb.

@dxL1nus @Subhanaliweb Please explain why this PR is still a "Draft". Who is best suited to resolve the merge conflicts?

@dxL1nus

dxL1nus commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the clarification @Subhanaliweb.

@dxL1nus @Subhanaliweb Please explain why this PR is still a "Draft". Who is best suited to resolve the merge conflicts?

this needs to stay a draft for now as well. I have to dicuss with Subhan what to do with the methods from the CodecheckMetadataHandler, as I moved them a couple months ago to the CodecheckApiController, but in his workflow, they are still inside the CodecheckMetadataHandler

@dxL1nus

dxL1nus commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

@nuest
I removed every useless test and also created a file: runTests.sh, to be able to run tests locally without executing the very long command. It also has a flag with which the testers can specify, if they want PHPUnit to also create a test coverage report (in HTML format) or not.

See here for the full instructions on how to run tests.

@nuest nuest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Primary change: remove the erroneously committed cache files, ideally also from the history.

Other changes: new extensive test patterns that I do not understand the benefit of; these can stay if it allows us to move on, but I would appreciate the help to understand the reasoning.

Comment thread .phpunit.cache/code-coverage/00b7a9638976680d9cdead19a11604a0 Outdated
Comment thread tests/FrontEndUnitTests/ArticleDetailsUnitTest.php Outdated
Comment thread tests/FrontEndUnitTests/ArticleDetailsUnitTest.php Outdated
Comment thread tests/MigrationUnitTests/CodecheckSchemaMigrationUnitTest.php Outdated
Comment thread tests/SubmissionUnitTests/CodecheckSubmissionDAOUnitTest.php Outdated
Comment thread tests/SubmissionUnitTests/SchemaUnitTest.php Outdated
Comment thread tests/WorkflowUnitTests/CodecheckMetadataHandlerUnitTest.php
Comment thread tests/ConstantsUnitTest.php Outdated
Comment thread tests/runTests.sh Outdated
Comment thread tests/runTests.sh Outdated
@nuest

nuest commented Mar 5, 2026

Copy link
Copy Markdown
Member

@Subhanaliweb Please take a look at the unresolved comments above - they are related to test classes you created. Thanks!

dxL1nus and others added 9 commits March 24, 2026 10:01
- Removed ConstantsUnitTest.php (testing constants is not behavioral)
- Removed SchemaUnitTest.php (schema tested by DAO tests)
- Removed CodecheckSchemaMigrationUnitTest.php (migration meta-test)
- Removed meta-tests (method existence, constants, return types)
- Kept only tests that verify actual behavior and logic
- Fixed assertion issues in DAO tests
- Use CSS class selectors instead of placeholder text
- Makes tests independent of translation mock
- Cypress doesn't support Vite 8 yet
- Vite 5.4.0 is the latest compatible version
- Runs PHPUnit tests with full OJS environment (stable-3_5_0)
- Runs Cypress component tests in parallel
- Generates code coverage reports with Xdebug
- Uploads artifacts (coverage, logs, screenshots)
- Uses GitHub secrets for API credentials
- Replaces old component-tests.yml with unified workflow
- Tests run on push to main and pull requests
@nuest nuest merged commit 5c0ec66 into codecheckers:main Apr 10, 2026
2 checks passed
nuest added a commit that referenced this pull request Apr 10, 2026
Closes: #36, closes: #74, closes: #75, closes: #76, closes: #77;

:warning: This PR needs to be merged after #63 and #79 ⚠️ 

This feature let's users import CODECHECK metadata from an already
existing `codecheck.yml` file in a codecheck repository, that is located
on one of the following platforms with the example repository links:
- `GitHub`: https://github.com/codecheckers/certificate-2025-029
- `Zenodo`: https://zenodo.org/records/14900193
- `OSF`: https://osf.io/ymc3t
- `GitLab`:
https://gitlab.com/cdchck/community-codechecks/2022-svaRetro-svaNUMT

To import metadata, simply paste the link to the repository root folder
and press `Load Metadata`.

<img width="2108" height="175" alt="Image"
src="https://github.com/user-attachments/assets/6de1f7f9-d0dc-4e0d-b114-ca2f806ecc14"
/>

When pressing the Info Button ℹ️ next to the Repositories Title, the
user gets presented with a promt, that describes, how the Repository
Functionality works along with the link to the documentation of the
CODECHECK Register where all Repository Types are described again in
more detail.

<img width="698" height="579" alt="Image"
src="https://github.com/user-attachments/assets/34b1b419-0ce9-4161-99f0-f7e9e6a1198e"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants