From 1758c2b58ce2fc24929c417c089d67b43fff242e Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Mon, 18 Jan 2021 17:26:19 +0530 Subject: [PATCH] Add tests for #28835 --- tests/php/includes/class-wc-emails-tests.php | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/php/includes/class-wc-emails-tests.php diff --git a/tests/php/includes/class-wc-emails-tests.php b/tests/php/includes/class-wc-emails-tests.php new file mode 100644 index 00000000000..e47126140ce --- /dev/null +++ b/tests/php/includes/class-wc-emails-tests.php @@ -0,0 +1,37 @@ +assertEquals( 10, has_action( 'woocommerce_email_header', array( $email_object, 'email_header' ) ) ); + ob_start(); + do_action( 'woocommerce_email_header', 'header' ); + $content = ob_get_contents(); + ob_end_clean(); + $this->assertFalse( empty( $content ) ); + } + + /** + * Test that email_footer hooks are compitable with do_action calls with only param. + * This test should be dropped after all extensions are using compitable do_action calls. + */ + public function test_email_footer_is_compatible_with_legacy_do_action() { + $email_object = new WC_Emails(); + // 10 is expected priority of the hook. + $this->assertEquals( 10, has_action( 'woocommerce_email_footer', array( $email_object, 'email_footer' ) ) ); + ob_start(); + do_action( 'woocommerce_email_footer' ); + $content = ob_get_contents(); + ob_end_clean(); + $this->assertFalse( empty( $content ) ); + } +}