-
Notifications
You must be signed in to change notification settings - Fork 6
Ensure patterns written to the filesystem in unit tests don't persist #185
Conversation
Fixes #168 (again)
Co-authored-by: Ryan Kienstra <kienstraryan@gmail.com>
Co-authored-by: Ryan Kienstra <kienstraryan@gmail.com>
…-bug-tests Update/patternception saving bug tests
* Add a naive function to update a slug * Use preg_replace() to update the slug
parent::setUp(); | ||
$this->stylesheet_dir = get_wp_filesystem_api()->wp_themes_dir() . '/pm-testing'; | ||
get_wp_filesystem_api()->mkdir( $this->stylesheet_dir ); | ||
add_filter( 'stylesheet_directory', [ $this, 'get_stylesheet_dir' ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this example, this makes get_patterns_directory() get the mock theme directory we created for these unit tests:$this->stylesheet_dir
.
* Add a naive function to update a slug * Handle multiple attributes in pattern block * Only output the name and textdomain if they exist
'post_name' => 'new-pattern-originally-created-with-pattern-manager', | ||
'post_type' => get_pattern_post_type(), | ||
] | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll revert this if you'd like. It's a tangent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it still works it's fine with me to keep :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks!
Thanks, @johnstonphilip! |
Summary of changes
At the end of each unit test, removes patterns written to the filesystem.
A follow-up to #183 (comment)
How do you know this PR does anything? These unit tests passed before this PR.
Fastest way:
git checkout add/setup-teardown
npm run test:phpunit
save_pattern_to_file()
calls inModelTest.php
npm run test:phpunit
save_pattern_to_file()
calls (the written patterns persisted after the tests)Slowest way:
git checkout 23e03b4fd3df77a5db029b6a98119b553c5c88a6
npm run test:phpunit
git checkout add/setup-teardown
npm run test:phpunit