-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathRESTAPITest.php
More file actions
76 lines (46 loc) · 1.72 KB
/
RESTAPITest.php
File metadata and controls
76 lines (46 loc) · 1.72 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
use SkyVerge\WooCommerce\PluginFramework\v6_0_1 as Framework;
use SkyVerge\WooCommerce\PluginFramework\v6_0_1\Settings_API\Abstract_Settings;
use SkyVerge\WooCommerce\PluginFramework\v6_0_1\SV_WC_Helper;
/**
* Tests for the REST_API class.
*
* @see \SkyVerge\WooCommerce\PluginFramework\v6_0_1\REST_API
*/
class RESTAPITest extends \Codeception\TestCase\WPTestCase {
/** @var \IntegrationTester */
protected $tester;
/** @var Abstract_Settings */
protected $settings;
protected function _before() {
require_once 'woocommerce/class-sv-wc-plugin.php';
require_once 'woocommerce/rest-api/Controllers/Settings.php';
require_once 'woocommerce/Settings_API/Abstract_Settings.php';
}
protected function _after() {
}
/** Tests *********************************************************************************************************/
/** @see Abstract_Settings::get_id() */
public function test_register_routes() {
$settings = $this->get_settings_instance();
$plugin = $this->make( SkyVerge\WooCommerce\TestPlugin\Plugin::class, [ 'get_settings_handler' => $settings ] );
$handler = new Framework\REST_API( $plugin );
$handler->register_routes();
$this->assertArrayHasKey( "/wc/v3/{$settings->get_id()}/settings", rest_get_server()->get_routes() );
}
/** Helper methods ************************************************************************************************/
/**
* Gets the settings instance.
*
* @return Abstract_Settings
*/
protected function get_settings_instance() {
if ( null === $this->settings ) {
$this->settings = new class( 'test-plugin' ) extends Abstract_Settings {
protected function register_settings() {
}
};
}
return $this->settings;
}
}