Skip to content

Commit dc9ee85

Browse files
committed
fix: catch wp_die stop exception in clone authorization test (#594)
cloneChart() calls wp_die() in the PHPUnit environment when the user cannot edit the source chart.
1 parent 28c09dd commit dc9ee85

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎tests/test-ajax.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,11 @@ public function test_clone_chart_denied_for_chart_user_cannot_edit() {
775775

776776
try {
777777
$this->_handleAjax( Visualizer_Plugin::ACTION_CLONE_CHART );
778+
$this->fail( 'Expected the request to die for a chart the user cannot edit.' );
779+
} catch ( WPAjaxDieStopException $e ) {
780+
// cloneChart() ends with wp_die() in the test environment when denied.
778781
} catch ( WPAjaxDieContinueException $e ) {
779-
// Expected when the handler ends.
782+
// Expected when the handler ends normally.
780783
}
781784

782785
$this->assertSame( $before, wp_count_posts( Visualizer_Plugin::CPT_VISUALIZER )->draft );

0 commit comments

Comments
 (0)