Implement incomplete and skipped tests#1242
Conversation
…Base_Sanitizer::remove_invalid_child()
…efactored classes
This was protected, so maybe it wasn't intended to have a test.
Also, reset $hook_source_stack in tearDown(). This is a basic test, and might be able to use more assertions.
This simply tests that it's a string of the proper length. It didn't seem like there was a need to test more.
This covers the two main conditional blocks. There is more space to test, but this might be enough for now.
There was an error in WP 4.7 and 4.8 in: test_decorate_shortcode_and_filter_source(). Still, this might to be reverted.
There were failures in WP 4.7 and the latest. So use a different method.
Maybe the variable $property was a copy, and setting its value didn't affect its class.
This was mainly implemented. But update it slightly.
In an attempt to address Travis errors. It might be that the variables were copies, and changing their value only changed the value of the copy.
test_finalize_validation() has failed in PHP 5.4, 5.5, 5.6.
This reverts commit 9d82383.
There have been test failures in PHP 5.4, 5.5, and 5.6. This might be related to the Reflection class. So remove this, to see it the test passes.
It looks like this worked in every PHP version except 5.3.
| // Hide irrelevant "published" label in the invalid URL post list. | ||
| add_filter( 'post_date_column_status', function( $status, $post ) { | ||
| if ( self::POST_TYPE_SLUG === get_post_type( $post ) ) { | ||
| if ( AMP_Invalid_URL_Post_Type::POST_TYPE_SLUG === get_post_type( $post ) ) { |
There was a problem hiding this comment.
It's great that we're going through this exercise of creating these tests now since otherwise this PHP 5.3 issue would have slipped through.
* Harden \AMP_Validation_Manager::validate_after_plugin_activation() * Rename \AMP_Validation_Manager::()plugin_notice to \AMP_Validation_Manager::print_plugin_notice()
Copies $error data from running this on the front end.
Also, abstract $error array() into get_mock_error().
Mainly uses the logic from the previous commit, like get_mock_error().
Also, store acceptable error in: self::MOCK_ACCEPTABLE_ERROR.
Create terms using the factory method. And simply verify that the counts are right.
Test 2 cases where the conditional isn't met, and 1 case where it is.
This only tests the hooks with method callbacks. There aren't callbacks yet for anonymous functions.
Test 2 conditions in the condition being false, and 1 where it's true.
…rors and add_admin_menu_new_invalid_url_count
I might not have understood the intention of the tested method.
This still needs an assertion for when the preg_replace() alters the WHERE clause. Also, add a full test for add_admin_notices().
Test cases where it doesn't filter the actions, and where it does.
Test that the submenu is added. Also, address failed Travis build in test_filter_tag_row_actions().
This would ideally test the number of errors. But this only worked locally when running the test in isolation.
Test for cases where it filters, and where it doesn't.
| $args = array( 'search' => 'baz' ); | ||
|
|
||
| // The condition won't be true, so it shouldn't alter the 'where' clause. | ||
| $this->assertEquals( $clauses, AMP_Validation_Error_Taxonomy::filter_terms_clauses_for_description_search( $clauses, array(), $args ) ); |
There was a problem hiding this comment.
The test stubs for the AMP_Validation_Error_Taxonomy are all implemented, but this method could still use another assertion, for the method's preg_replace().
…n_error_counts_summary and get_invalid_url_post
Begin by testing a case where it doesn't change the items. Then, create validation errors so that it can add items.
…olumns, output_custom_column, filter_row_actions, add_bulk_action, handle_bulk_action, print_admin_notice
…eck_post, handle_validation_error_status_update, add_meta_boxes, and print_status_meta_box
Test for 2 cases where the conditional is false, ad 1 where it's true.
…box and get_recheck_url
This didn't test the preg_replace() call before. Also, fix DocBlock for TESTED_CLASS.
kienstra
left a comment
There was a problem hiding this comment.
Approved
Hi @westonruter,
These unit tests looks good. They'll give us more confidence going into the release.
I made commit e783ae below to add some assertions to a test I wrote, and correct a DocBlock I had added.
| $post = get_post( $post ); | ||
| $url = self::get_url_from_post( $post ); | ||
| if ( ! $post ) { | ||
| return new WP_Error( 'missing_post' ); |
There was a problem hiding this comment.
Nice use of errors to clarify what happened.
| */ | ||
| public static function handle_save_post_prompting_validation( $post_id, $post ) { | ||
| public static function handle_save_post_prompting_validation( $post_id ) { | ||
| $post = get_post( $post_id ); |
There was a problem hiding this comment.
Good idea to simply get the post from the $post_id.
| public function tearDown() { | ||
| global $current_screen; | ||
| parent::tearDown(); | ||
| $current_screen = null; // WPCS: override ok. |
There was a problem hiding this comment.
Good idea to reset $current_screen in the tearDown().
AMP_Base_Sanitizer::remove_invalid_attribute()andAMP_Base_Sanitizer::remove_invalid_child()(andshould_sanitize_validation_error,prepare_validation_errormethods)test-class-amp-validation-utils.phpto correspond to the breakup ofAMP_Validation_UtilsintoAMP_Validation_Manager,AMP_Invalid_URL_Post_Type, andAMP_Validation_Error_Taxonomy.