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 integration tests #393

Merged
merged 17 commits into from
Mar 11, 2024
Merged

Add integration tests #393

merged 17 commits into from
Mar 11, 2024

Conversation

vcanales
Copy link
Member

@vcanales vcanales commented Jun 7, 2023

To facilitate future improvements to the codebase, this proposes configuring PHPUnit to be able to write tests for the plugin.

This was created using wp scaffold plugin-test, plus some modifications to add wp-cli and theme data to the test site.

A first test is included at tests/test-theme-create-theme.php.

Testing

To run this suite, a local MySQL installation is required. After that is taken care of, the following commands should get everything setup:

# install dependencies
composer install
./bin/install-wp-tests.sh
# run tests
npm run test:php

@vcanales vcanales added the enhancement New feature or request label Jun 7, 2023
@vcanales vcanales self-assigned this Jun 7, 2023
Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! It'd be great to have a suite of tests.

The changes are reading well for me. Are there any commands I can try running locally to test this better? Or maybe just ensure that the new test at tests/test-theme-create-theme.php passes?

admin/class-create-theme.php Show resolved Hide resolved
@vcanales
Copy link
Member Author

vcanales commented Jun 8, 2023

@mikachan The changes are reading well for me. Are there any commands I can try running locally to test this better? Or maybe just ensure that the new test at tests/test-theme-create-theme.php passes?

I've added testing instructions to the description.

Testing

To run this suite, a local MySQL installation is required. After that is taken care of, the following commands should get everything setup:

# install dependencies
composer install
./bin/install-wp-tests.sh
# run tests
npm run test:php

@vcanales
Copy link
Member Author

vcanales commented Jun 9, 2023

I added a GitHub actions, which you can see working on this very PR. This required me to add back the changes made for #379 to get tests passing :)

@vcanales vcanales changed the title Add unit tests with PHPUnit Add integration tests with PHPUnit Jun 14, 2023
@vcanales vcanales changed the title Add integration tests with PHPUnit Add integration tests Jun 14, 2023
@vcanales vcanales marked this pull request as draft June 14, 2023 00:54
Starting with the export_child_theme method.
Refactors test installation script for it to be able to run in a CI
context without requiring user input

try adding test action

add mysql setup

fix wp config creation command

overwrite if it exists

create wpconfig before install attempt

move musql config to test step

fix multiple command syntax

add missing command

add option to recreate db from cli

Helps us skip the prompt for user input

move cli options to the end

add host to command call

refactor to add options at the beginning

try different order

add missing steps

use config create instead of core create

skip check on config creation

change to 127.0.0.1 as default host

install composer dependencies

refactor composer action

install dev dependencies

refactor Lint action

silence stdout from test installation script

pretty print tests

do not profile composer
Required to get sample test passing
@vcanales vcanales marked this pull request as ready for review March 8, 2024 19:45
@pbking
Copy link
Contributor

pbking commented Mar 11, 2024

Added a command to run tests in watch mode. npm run test:php:watch

Copy link
Contributor

@pbking pbking left a comment

Choose a reason for hiding this comment

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

Ready to test now!

@pbking pbking merged commit 1545d48 into trunk Mar 11, 2024
2 checks passed
@pbking pbking deleted the add-unit-tests branch March 11, 2024 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants