From dde788631cb50692f96c9bfeac0d8c28647d51db Mon Sep 17 00:00:00 2001 From: Timmy Crawford Date: Mon, 8 Jul 2019 09:48:38 -0700 Subject: [PATCH] Notes: Type cast is_snoozeable on insert. (https://github.com/woocommerce/woocommerce-admin/pull/2573) --- .../includes/data-stores/class-wc-admin-notes-data-store.php | 2 +- plugins/woocommerce-admin/tests/api/admin-notes.php | 2 ++ .../tests/framework/helpers/class-wc-helper-admin-notes.php | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-notes-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-notes-data-store.php index 70b6052af95..130c6da904e 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-notes-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-notes-data-store.php @@ -31,7 +31,7 @@ class WC_Admin_Notes_Data_Store extends WC_Data_Store_WP implements WC_Object_Da 'icon' => $note->get_icon(), 'status' => $note->get_status(), 'source' => $note->get_source(), - 'is_snoozable' => $note->get_is_snoozable(), + 'is_snoozable' => (int) $note->get_is_snoozable(), ); $note_to_be_inserted['content_data'] = wp_json_encode( $note->get_content_data() ); diff --git a/plugins/woocommerce-admin/tests/api/admin-notes.php b/plugins/woocommerce-admin/tests/api/admin-notes.php index 54b63a23c94..e6124dc735d 100644 --- a/plugins/woocommerce-admin/tests/api/admin-notes.php +++ b/plugins/woocommerce-admin/tests/api/admin-notes.php @@ -176,6 +176,7 @@ class WC_Tests_API_Admin_Notes extends WC_REST_Unit_Test_Case { $this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 1, count( $notes ) ); $this->assertEquals( $notes[0]['title'], 'PHPUNIT_TEST_NOTE_2_TITLE' ); + $this->assertEquals( $notes[0]['is_snoozable'], true ); } @@ -247,6 +248,7 @@ class WC_Tests_API_Admin_Notes extends WC_REST_Unit_Test_Case { $this->assertEquals( 200, $response->get_status() ); $this->assertEquals( 3, count( $notes ) ); $this->assertEquals( $notes[0]['title'], 'PHPUNIT_TEST_NOTE_1_TITLE' ); + $this->assertEquals( $notes[0]['is_snoozable'], false ); $this->assertEquals( $notes[1]['title'], 'PHPUNIT_TEST_NOTE_2_TITLE' ); $this->assertEquals( $notes[2]['title'], 'PHPUNIT_TEST_NOTE_3_TITLE' ); diff --git a/plugins/woocommerce-admin/tests/framework/helpers/class-wc-helper-admin-notes.php b/plugins/woocommerce-admin/tests/framework/helpers/class-wc-helper-admin-notes.php index 2dcfebdfa4e..059871d4f78 100644 --- a/plugins/woocommerce-admin/tests/framework/helpers/class-wc-helper-admin-notes.php +++ b/plugins/woocommerce-admin/tests/framework/helpers/class-wc-helper-admin-notes.php @@ -35,6 +35,7 @@ class WC_Helper_Admin_Notes { $note_1->set_icon( 'info' ); $note_1->set_name( 'PHPUNIT_TEST_NOTE_NAME' ); $note_1->set_source( 'PHPUNIT_TEST' ); + $note_1->set_is_snoozable( false ); $note_1->add_action( 'PHPUNIT_TEST_NOTE_1_ACTION_1_SLUG', 'PHPUNIT_TEST_NOTE_1_ACTION_1_LABEL', @@ -56,6 +57,7 @@ class WC_Helper_Admin_Notes { $note_2->set_name( 'PHPUNIT_TEST_NOTE_NAME' ); $note_2->set_source( 'PHPUNIT_TEST' ); $note_2->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED ); + $note_2->set_is_snoozable( true ); // This note has no actions. $note_2->save();