Skip to content

Commit

Permalink
Add test for sanitize_type
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-mendonca committed Jul 14, 2024
1 parent 3fcc650 commit a824561
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions tests/phpunit/includes/test-admin-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,76 @@ public function test_message() {

}

/**
* Data provider.
*
* @var array
*/
public function provide_test_sanitize_type() {
return array(
// Supported.
array(
'type' => 'error',
'expected_result' => 'notice-warning',
),
array(
'type' => 'warning',
'expected_result' => 'notice-warning',
),
array(
'type' => 'warning-spin',
'expected_result' => 'notice-warning-spin',
),
array(
'type' => 'success',
'expected_result' => 'notice-success',
),
array(
'type' => 'info',
'expected_result' => 'notice-info',
),
// Not supported.
array(
'type' => 'other',
'expected_result' => '',
),
array(
'type' => '',
'expected_result' => '',
),
array(
'type' => null,
'expected_result' => '',
),
array(
'type' => false,
'expected_result' => '',
),
array(
'type' => true,
'expected_result' => '',
),
array(
'type' => array(),
'expected_result' => '',
),
);
}

/**
* Test type sanitization.
*
* @dataProvider provide_test_sanitize_type
*/
public function test_sanitize_type( $type, $expected_result ) {

$args = array(
'type' => $type;
);

$admin_notice = new Admin_Notice( $args );

$this->assertSame( $admin_notice->type, $expected_result );

}
}

0 comments on commit a824561

Please sign in to comment.