Skip to content

NEW unit tests for the Import & Export classes#937

Merged
mauteri merged 20 commits intoGatherPress:developfrom
carstingaxion:fix/unit-test-migrate-classes
Oct 10, 2024
Merged

NEW unit tests for the Import & Export classes#937
mauteri merged 20 commits intoGatherPress:developfrom
carstingaxion:fix/unit-test-migrate-classes

Conversation

@carstingaxion
Copy link
Copy Markdown
Collaborator

@carstingaxion carstingaxion commented Oct 4, 2024

Description of the Change

Closes #

How to test the Change

npm run test:unit:php -- --group migrate

Changelog Entry

Added - New unit tests for the Import & Export classes

Credits

Props @carstingaxion @mauteri

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Oct 4, 2024

PR Summary

  • Improved Data Handling in 'class-import.php'
    The revamped approach in processing $data adds a layer of safety by assuring that it's always treated as an array in certain one of its functions, datetimes_callback.

  • New 'migrate' Category for Certain Tests
    We've embedded a 'migrate' tag feature in our testing script class-test-export.php. This new feature allows better categorization of tests that are primarily related to data migration.

  • Additional Tests in 'class-test-import.php'
    Numerous tests are introduced in class-test-import.php to cover several methods such as prepare, validate, extend, run, and datetimes_callback. We added varying conditions including tests for both valid and invalid post data, improving our system reliability.

  • Enhanced Organization for Migration-Related Tests
    A new 'migrate' tag is introduced in class-test-migrate.php. This addition aims to better organize the tests pertaining to data migration.

@carstingaxion
Copy link
Copy Markdown
Collaborator Author

carstingaxion commented Oct 4, 2024

Hello @mauteri ,

can you please help me here, please?

I'm wondering if the failing unit-test should be fixed rather in class-import.php or maybe better in class-event.php as it could be helpful to check if the needed array keys exist before saving.

What do you think?

@carstingaxion carstingaxion marked this pull request as ready for review October 5, 2024 17:29
@mauteri mauteri changed the base branch from main to develop October 10, 2024 12:57
*/
protected function validate( WP_Post $post ): bool {
return ( Event::POST_TYPE === $post->post_type );
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add this to the new Validate class. Validate::event_post_type( $post )

https://github.com/GatherPress/gatherpress/blob/develop/includes/core/classes/class-validate.php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

never mind, we can use Validate::event_post_id here.

@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#937 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri merged commit a0518fa into GatherPress:develop Oct 10, 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.

2 participants