File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
projects/packages/forms/tests/php/contact-form Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -720,7 +720,12 @@ public function test_mark_feedback_as_read() {
720
720
),
721
721
'Test message ' ,
722
722
'Test User ' ,
723
-
723
+
724
+ '' ,
725
+ '' ,
726
+ 'publish ' ,
727
+ false ,
728
+ true // is_unread
724
729
);
725
730
726
731
// Mark as read
@@ -738,12 +743,10 @@ public function test_mark_feedback_as_read() {
738
743
$ response = $ this ->server ->dispatch ( $ request );
739
744
$ data = $ response ->get_data ();
740
745
$ this ->assertFalse ( $ data ['is_unread ' ] );
741
- $ this ->assertIsInt ( 0 , Contact_Form_Plugin::get_unread_count () );
742
746
743
747
// Verify Feedback class method
744
748
$ feedback = \Automattic \Jetpack \Forms \ContactForm \Feedback::get ( $ post_id );
745
749
$ this ->assertFalse ( $ feedback ->is_unread () );
746
- $ this ->assertIsInt ( 1 , Contact_Form_Plugin::get_unread_count () );
747
750
}
748
751
749
752
/**
Original file line number Diff line number Diff line change @@ -844,4 +844,23 @@ public function test_interpersonal_data_exporter() {
844
844
);
845
845
$ this ->assertIsArray ( $ exporter , 'Expected the exporter to return an array. ' );
846
846
}
847
+
848
+ public function test_get_unread_count_zero () {
849
+ delete_option ( 'jetpack_feedback_unread_count ' );
850
+ $ this ->assertIsInt ( Contact_Form_Plugin::get_unread_count () );
851
+ $ this ->assertGreaterThanOrEqual ( 0 , Contact_Form_Plugin::get_unread_count () );
852
+ }
853
+
854
+ public function test_get_unread_count_nonzero () {
855
+ update_option ( 'jetpack_feedback_unread_count ' , 5 );
856
+ $ this ->assertEquals ( 5 , Contact_Form_Plugin::get_unread_count () );
857
+ delete_option ( 'jetpack_feedback_unread_count ' );
858
+ }
859
+
860
+ public function test_recalculate_unread_count () {
861
+ update_option ( 'jetpack_feedback_unread_count ' , 5 );
862
+ $ this ->assertEquals ( 5 , Contact_Form_Plugin::get_unread_count () );
863
+ Contact_Form_Plugin::recalculate_unread_count ();
864
+ $ this ->assertSame ( 0 , Contact_Form_Plugin::get_unread_count () );
865
+ }
847
866
}
You can’t perform that action at this time.
0 commit comments