forked from petenelson/wp-rest-api-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-prefix.php
39 lines (21 loc) · 1.26 KB
/
test-prefix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
class REST_API_Toolbox_Test_Prefix extends REST_API_Toolbox_Test_Base {
function sanitize_callback() {
return 'REST_API_Toolbox_Settings_General::sanitize_general_settings';
}
function test_changed_prefix() {
REST_API_Toolbox_Settings_General::change_setting( 'general', 'rest-api-prefix', 'hello-world', $this->sanitize_callback() );
$this->assertEquals( 'hello-world', REST_API_Toolbox_Settings_General::setting_get( 'general', 'rest-api-prefix' ) );
$this->assertEquals( 'hello-world', rest_get_url_prefix() );
}
function test_unchanged_prefix() {
REST_API_Toolbox_Settings_General::change_setting( 'general', 'rest-api-prefix', '', $this->sanitize_callback() );
$this->assertEquals( '', REST_API_Toolbox_Settings_General::setting_get( 'general', 'rest-api-prefix' ), $this->sanitize_callback() );
$this->assertEquals( 'wp-json', rest_get_url_prefix() );
}
function test_sanitized_prefix() {
REST_API_Toolbox_Settings_General::change_setting( 'general', 'rest-api-prefix', 'he||o /world<', $this->sanitize_callback() ); // invalid URL, will be sanitized
$this->assertEquals( 'heo-world', REST_API_Toolbox_Settings_General::setting_get( 'general', 'rest-api-prefix' ) );
$this->assertEquals( 'heo-world', rest_get_url_prefix() );
}
}