Skip to content

Commit 3e0f19c

Browse files
committed
Update the tests to remove untestable code
1 parent 7da12f0 commit 3e0f19c

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

projects/packages/forms/tests/php/contact-form/Contact_Form_Endpoint_Test.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,12 @@ public function test_mark_feedback_as_read() {
720720
),
721721
'Test message',
722722
'Test User',
723-
723+
724+
'',
725+
'',
726+
'publish',
727+
false,
728+
true // is_unread
724729
);
725730

726731
// Mark as read
@@ -738,12 +743,10 @@ public function test_mark_feedback_as_read() {
738743
$response = $this->server->dispatch( $request );
739744
$data = $response->get_data();
740745
$this->assertFalse( $data['is_unread'] );
741-
$this->assertIsInt( 0, Contact_Form_Plugin::get_unread_count() );
742746

743747
// Verify Feedback class method
744748
$feedback = \Automattic\Jetpack\Forms\ContactForm\Feedback::get( $post_id );
745749
$this->assertFalse( $feedback->is_unread() );
746-
$this->assertIsInt( 1, Contact_Form_Plugin::get_unread_count() );
747750
}
748751

749752
/**

projects/packages/forms/tests/php/contact-form/Contact_Form_Plugin_Test.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,4 +844,23 @@ public function test_interpersonal_data_exporter() {
844844
);
845845
$this->assertIsArray( $exporter, 'Expected the exporter to return an array.' );
846846
}
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+
}
847866
}

0 commit comments

Comments
 (0)