Completed
Push — master ( adb8dc...103e24 )
by Mike
04:42 queued 01:51
created
unit-tests/Tests/Version4/Reports/Variations.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace WooCommerce\RestApi\UnitTests\Tests\Version4\Reports;
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 use \WooCommerce\RestApi\UnitTests\AbstractReportsTest;
14 14
 use \WP_REST_Request;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	public function test_register_routes() {
40 40
 		$routes = $this->server->get_routes();
41 41
 
42
-		$this->assertArrayHasKey( $this->endpoint, $routes );
42
+		$this->assertArrayHasKey($this->endpoint, $routes);
43 43
 	}
44 44
 
45 45
 	/**
@@ -50,33 +50,33 @@  discard block
 block discarded – undo
50 50
 	public function test_get_reports() {
51 51
 		// Populate all of the data.
52 52
 		$variation = new \WC_Product_Variation();
53
-		$variation->set_name( 'Test Variation' );
54
-		$variation->set_regular_price( 25 );
55
-		$variation->set_attributes( array( 'color' => 'green' ) );
53
+		$variation->set_name('Test Variation');
54
+		$variation->set_regular_price(25);
55
+		$variation->set_attributes(array('color' => 'green'));
56 56
 		$variation->save();
57 57
 
58
-		$order = OrderHelper::create_order( 1, $variation );
59
-		$order->set_status( 'completed' );
60
-		$order->set_total( 100 ); // $25 x 4.
58
+		$order = OrderHelper::create_order(1, $variation);
59
+		$order->set_status('completed');
60
+		$order->set_total(100); // $25 x 4.
61 61
 		$order->save();
62 62
 
63 63
 		QueueHelper::run_all_pending();
64 64
 
65
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', $this->endpoint ) );
65
+		$response = $this->server->dispatch(new WP_REST_Request('GET', $this->endpoint));
66 66
 		$reports  = $response->get_data();
67 67
 
68
-		$this->assertEquals( 200, $response->get_status() );
69
-		$this->assertEquals( 1, count( $reports ) );
68
+		$this->assertEquals(200, $response->get_status());
69
+		$this->assertEquals(1, count($reports));
70 70
 
71
-		$variation_report = reset( $reports );
71
+		$variation_report = reset($reports);
72 72
 
73
-		$this->assertEquals( $variation->get_id(), $variation_report['variation_id'] );
74
-		$this->assertEquals( 4, $variation_report['items_sold'] );
75
-		$this->assertEquals( 1, $variation_report['orders_count'] );
76
-		$this->assertArrayHasKey( '_links', $variation_report );
77
-		$this->assertArrayHasKey( 'extended_info', $variation_report );
78
-		$this->assertArrayHasKey( 'product', $variation_report['_links'] );
79
-		$this->assertArrayHasKey( 'variation', $variation_report['_links'] );
73
+		$this->assertEquals($variation->get_id(), $variation_report['variation_id']);
74
+		$this->assertEquals(4, $variation_report['items_sold']);
75
+		$this->assertEquals(1, $variation_report['orders_count']);
76
+		$this->assertArrayHasKey('_links', $variation_report);
77
+		$this->assertArrayHasKey('extended_info', $variation_report);
78
+		$this->assertArrayHasKey('product', $variation_report['_links']);
79
+		$this->assertArrayHasKey('variation', $variation_report['_links']);
80 80
 	}
81 81
 
82 82
 	/**
@@ -87,25 +87,25 @@  discard block
 block discarded – undo
87 87
 	public function test_get_reports_variations_param() {
88 88
 		// Populate all of the data.
89 89
 		$variation = new \WC_Product_Variation();
90
-		$variation->set_name( 'Test Variation' );
91
-		$variation->set_regular_price( 25 );
92
-		$variation->set_attributes( array( 'color' => 'green' ) );
90
+		$variation->set_name('Test Variation');
91
+		$variation->set_regular_price(25);
92
+		$variation->set_attributes(array('color' => 'green'));
93 93
 		$variation->save();
94 94
 
95 95
 		$variation_2 = new \WC_Product_Variation();
96
-		$variation_2->set_name( 'Test Variation 2' );
97
-		$variation_2->set_regular_price( 100 );
98
-		$variation_2->set_attributes( array( 'color' => 'red' ) );
96
+		$variation_2->set_name('Test Variation 2');
97
+		$variation_2->set_regular_price(100);
98
+		$variation_2->set_attributes(array('color' => 'red'));
99 99
 		$variation_2->save();
100 100
 
101
-		$order = OrderHelper::create_order( 1, $variation );
102
-		$order->set_status( 'completed' );
103
-		$order->set_total( 100 ); // $25 x 4.
101
+		$order = OrderHelper::create_order(1, $variation);
102
+		$order->set_status('completed');
103
+		$order->set_total(100); // $25 x 4.
104 104
 		$order->save();
105 105
 
106 106
 		QueueHelper::run_all_pending();
107 107
 
108
-		$request = new WP_REST_Request( 'GET', $this->endpoint );
108
+		$request = new WP_REST_Request('GET', $this->endpoint);
109 109
 		$request->set_query_params(
110 110
 			array(
111 111
 				'product_includes' => $variation->get_parent_id(),
@@ -113,31 +113,31 @@  discard block
 block discarded – undo
113 113
 				'variations'       => $variation->get_id() . ',' . $variation_2->get_id(),
114 114
 			)
115 115
 		);
116
-		$response = $this->server->dispatch( $request );
116
+		$response = $this->server->dispatch($request);
117 117
 		$reports  = $response->get_data();
118 118
 
119
-		$this->assertEquals( 200, $response->get_status() );
120
-		$this->assertEquals( 2, count( $reports ) );
119
+		$this->assertEquals(200, $response->get_status());
120
+		$this->assertEquals(2, count($reports));
121 121
 
122
-		$variation_report = reset( $reports );
122
+		$variation_report = reset($reports);
123 123
 
124
-		$this->assertEquals( $variation->get_id(), $variation_report['variation_id'] );
125
-		$this->assertEquals( 4, $variation_report['items_sold'] );
126
-		$this->assertEquals( 1, $variation_report['orders_count'] );
127
-		$this->assertArrayHasKey( '_links', $variation_report );
128
-		$this->assertArrayHasKey( 'extended_info', $variation_report );
129
-		$this->assertArrayHasKey( 'product', $variation_report['_links'] );
130
-		$this->assertArrayHasKey( 'variation', $variation_report['_links'] );
124
+		$this->assertEquals($variation->get_id(), $variation_report['variation_id']);
125
+		$this->assertEquals(4, $variation_report['items_sold']);
126
+		$this->assertEquals(1, $variation_report['orders_count']);
127
+		$this->assertArrayHasKey('_links', $variation_report);
128
+		$this->assertArrayHasKey('extended_info', $variation_report);
129
+		$this->assertArrayHasKey('product', $variation_report['_links']);
130
+		$this->assertArrayHasKey('variation', $variation_report['_links']);
131 131
 
132
-		$variation_report = next( $reports );
132
+		$variation_report = next($reports);
133 133
 
134
-		$this->assertEquals( $variation_2->get_id(), $variation_report['variation_id'] );
135
-		$this->assertEquals( 0, $variation_report['items_sold'] );
136
-		$this->assertEquals( 0, $variation_report['orders_count'] );
137
-		$this->assertArrayHasKey( '_links', $variation_report );
138
-		$this->assertArrayHasKey( 'extended_info', $variation_report );
139
-		$this->assertArrayHasKey( 'product', $variation_report['_links'] );
140
-		$this->assertArrayHasKey( 'variation', $variation_report['_links'] );
134
+		$this->assertEquals($variation_2->get_id(), $variation_report['variation_id']);
135
+		$this->assertEquals(0, $variation_report['items_sold']);
136
+		$this->assertEquals(0, $variation_report['orders_count']);
137
+		$this->assertArrayHasKey('_links', $variation_report);
138
+		$this->assertArrayHasKey('extended_info', $variation_report);
139
+		$this->assertArrayHasKey('product', $variation_report['_links']);
140
+		$this->assertArrayHasKey('variation', $variation_report['_links']);
141 141
 	}
142 142
 
143 143
 	/**
@@ -146,9 +146,9 @@  discard block
 block discarded – undo
146 146
 	 * @since 3.5.0
147 147
 	 */
148 148
 	public function test_get_reports_without_permission() {
149
-		wp_set_current_user( 0 );
150
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', $this->endpoint ) );
151
-		$this->assertEquals( 401, $response->get_status() );
149
+		wp_set_current_user(0);
150
+		$response = $this->server->dispatch(new WP_REST_Request('GET', $this->endpoint));
151
+		$this->assertEquals(401, $response->get_status());
152 152
 	}
153 153
 
154 154
 	/**
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
 	 * @since 3.5.0
158 158
 	 */
159 159
 	public function test_reports_schema() {
160
-		$request    = new WP_REST_Request( 'OPTIONS', $this->endpoint );
161
-		$response   = $this->server->dispatch( $request );
160
+		$request    = new WP_REST_Request('OPTIONS', $this->endpoint);
161
+		$response   = $this->server->dispatch($request);
162 162
 		$data       = $response->get_data();
163 163
 		$properties = $data['schema']['properties'];
164 164
 
165
-		$this->assertEquals( 6, count( $properties ) );
166
-		$this->assertArrayHasKey( 'product_id', $properties );
167
-		$this->assertArrayHasKey( 'variation_id', $properties );
168
-		$this->assertArrayHasKey( 'items_sold', $properties );
169
-		$this->assertArrayHasKey( 'net_revenue', $properties );
170
-		$this->assertArrayHasKey( 'orders_count', $properties );
171
-		$this->assertArrayHasKey( 'extended_info', $properties );
165
+		$this->assertEquals(6, count($properties));
166
+		$this->assertArrayHasKey('product_id', $properties);
167
+		$this->assertArrayHasKey('variation_id', $properties);
168
+		$this->assertArrayHasKey('items_sold', $properties);
169
+		$this->assertArrayHasKey('net_revenue', $properties);
170
+		$this->assertArrayHasKey('orders_count', $properties);
171
+		$this->assertArrayHasKey('extended_info', $properties);
172 172
 	}
173 173
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Data.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace WooCommerce\RestApi\UnitTests\Tests\Version4;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 use \WooCommerce\RestApi\UnitTests\AbstractReportsTest;
13 13
 
@@ -27,13 +27,13 @@  discard block
 block discarded – undo
27 27
 	 * Test that the list of data endpoints includes download-ips.
28 28
 	 */
29 29
 	public function test_get_items_contains_download_ips() {
30
-		$request  = new \WP_REST_Request( 'GET', $this->endpoint );
31
-		$response = $this->server->dispatch( $request );
30
+		$request  = new \WP_REST_Request('GET', $this->endpoint);
31
+		$response = $this->server->dispatch($request);
32 32
 		$data     = $response->get_data();
33 33
 
34
-		$this->assertEquals( 200, $response->get_status() );
35
-		$this->assertEquals( 4, count( $data ) );
36
-		$this->assertEquals( 'download-ips', $data[3]['slug'] );
34
+		$this->assertEquals(200, $response->get_status());
35
+		$this->assertEquals(4, count($data));
36
+		$this->assertEquals('download-ips', $data[3]['slug']);
37 37
 	}
38 38
 
39 39
 	/**
@@ -41,67 +41,67 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function test_download_ips() {
43 43
 		$prod_download = new \WC_Product_Download();
44
-		$prod_download->set_file( plugin_dir_url( __FILE__ ) . '/assets/images/help.png' );
45
-		$prod_download->set_id( 1 );
44
+		$prod_download->set_file(plugin_dir_url(__FILE__) . '/assets/images/help.png');
45
+		$prod_download->set_id(1);
46 46
 
47 47
 		$product = new \WC_Product_Simple();
48
-		$product->set_name( 'Test Product' );
49
-		$product->set_downloadable( 'yes' );
50
-		$product->set_downloads( array( $prod_download ) );
51
-		$product->set_regular_price( 25 );
48
+		$product->set_name('Test Product');
49
+		$product->set_downloadable('yes');
50
+		$product->set_downloads(array($prod_download));
51
+		$product->set_regular_price(25);
52 52
 		$product->save();
53 53
 
54
-		$order = \WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order( 1, $product );
55
-		$order->set_status( 'completed' );
56
-		$order->set_total( 100 );
54
+		$order = \WooCommerce\RestApi\UnitTests\Helpers\OrderHelper::create_order(1, $product);
55
+		$order->set_status('completed');
56
+		$order->set_total(100);
57 57
 		$order->save();
58 58
 
59 59
 		$download = new \WC_Customer_Download();
60
-		$download->set_user_id( $this->user );
61
-		$download->set_order_id( $order->get_id() );
62
-		$download->set_product_id( $product->get_id() );
63
-		$download->set_download_id( $prod_download->get_id() );
60
+		$download->set_user_id($this->user);
61
+		$download->set_order_id($order->get_id());
62
+		$download->set_product_id($product->get_id());
63
+		$download->set_download_id($prod_download->get_id());
64 64
 		$download->save();
65 65
 
66 66
 		$object = new \WC_Customer_Download_Log();
67
-		$object->set_permission_id( $download->get_id() );
68
-		$object->set_user_id( $this->user );
69
-		$object->set_user_ip_address( '1.2.3.4' );
67
+		$object->set_permission_id($download->get_id());
68
+		$object->set_user_id($this->user);
69
+		$object->set_user_ip_address('1.2.3.4');
70 70
 		$id = $object->save();
71 71
 
72 72
 		$object = new \WC_Customer_Download_Log();
73
-		$object->set_permission_id( $download->get_id() );
74
-		$object->set_user_id( $this->user );
75
-		$object->set_user_ip_address( '54.2.1.3' );
73
+		$object->set_permission_id($download->get_id());
74
+		$object->set_user_id($this->user);
75
+		$object->set_user_ip_address('54.2.1.3');
76 76
 		$id = $object->save();
77 77
 
78 78
 		// Save a second log for the same IP -- only one result for this IP should be returned.
79 79
 		$object = new \WC_Customer_Download_Log();
80
-		$object->set_permission_id( $download->get_id() );
81
-		$object->set_user_id( $this->user );
82
-		$object->set_user_ip_address( '54.2.1.3' );
80
+		$object->set_permission_id($download->get_id());
81
+		$object->set_user_id($this->user);
82
+		$object->set_user_ip_address('54.2.1.3');
83 83
 		$id = $object->save();
84 84
 
85 85
 		$object = new \WC_Customer_Download_Log();
86
-		$object->set_permission_id( $download->get_id() );
87
-		$object->set_user_id( $this->user );
88
-		$object->set_user_ip_address( '54.5.1.7' );
86
+		$object->set_permission_id($download->get_id());
87
+		$object->set_user_id($this->user);
88
+		$object->set_user_ip_address('54.5.1.7');
89 89
 		$id = $object->save();
90 90
 
91
-		$request = new \WP_REST_Request( 'GET', $this->endpoint . '/download-ips' );
91
+		$request = new \WP_REST_Request('GET', $this->endpoint . '/download-ips');
92 92
 		$request->set_query_params(
93 93
 			array(
94 94
 				'match' => '54',
95 95
 			)
96 96
 		);
97 97
 
98
-		$response  = $this->server->dispatch( $request );
98
+		$response  = $this->server->dispatch($request);
99 99
 		$addresses = $response->get_data();
100 100
 
101
-		$this->assertEquals( 200, $response->get_status() );
102
-		$this->assertEquals( 2, count( $addresses ) );
101
+		$this->assertEquals(200, $response->get_status());
102
+		$this->assertEquals(2, count($addresses));
103 103
 
104
-		$this->assertEquals( '54.2.1.3', $addresses[0]['user_ip_address'] );
105
-		$this->assertEquals( '54.5.1.7', $addresses[1]['user_ip_address'] );
104
+		$this->assertEquals('54.2.1.3', $addresses[0]['user_ip_address']);
105
+		$this->assertEquals('54.5.1.7', $addresses[1]['user_ip_address']);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/Settings.php 1 patch
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace WooCommerce\RestApi\UnitTests\Tests\Version4;
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 use \WP_REST_Request;
14 14
 use \WC_REST_Unit_Test_Case;
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 *
29 29
 	 * @param object $factory Factory object.
30 30
 	 */
31
-	public static function wpSetUpBeforeClass( $factory ) {
31
+	public static function wpSetUpBeforeClass($factory) {
32 32
 		self::$user = $factory->user->create(
33 33
 			array(
34 34
 				'role' => 'administrator',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public function setUp() {
43 43
 		parent::setUp();
44
-		wp_set_current_user( self::$user );
44
+		wp_set_current_user(self::$user);
45 45
 		SettingsHelper::register();
46 46
 		$this->zones = array();
47 47
 	}
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function test_register_routes() {
55 55
 		$routes = $this->server->get_routes();
56
-		$this->assertArrayHasKey( '/wc/v4/settings', $routes );
57
-		$this->assertArrayHasKey( '/wc/v4/settings/(?P<group_id>[\w-]+)', $routes );
58
-		$this->assertArrayHasKey( '/wc/v4/settings/(?P<group_id>[\w-]+)/(?P<id>[\w-]+)', $routes );
56
+		$this->assertArrayHasKey('/wc/v4/settings', $routes);
57
+		$this->assertArrayHasKey('/wc/v4/settings/(?P<group_id>[\w-]+)', $routes);
58
+		$this->assertArrayHasKey('/wc/v4/settings/(?P<group_id>[\w-]+)/(?P<id>[\w-]+)', $routes);
59 59
 	}
60 60
 
61 61
 	/**
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 * @since 3.5.0
65 65
 	 */
66 66
 	public function test_get_groups() {
67
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings' ) );
67
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings'));
68 68
 		$data     = $response->get_data();
69 69
 
70
-		$this->assertEquals( 200, $response->get_status() );
70
+		$this->assertEquals(200, $response->get_status());
71 71
 
72 72
 		$this->assertContains(
73 73
 			array(
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 				'label'       => 'Test extension',
76 76
 				'parent_id'   => '',
77 77
 				'description' => 'My awesome test settings.',
78
-				'sub_groups'  => array( 'sub-test' ),
78
+				'sub_groups'  => array('sub-test'),
79 79
 				'_links'      => array(
80 80
 					'options' => array(
81 81
 						array(
82
-							'href' => rest_url( '/wc/v4/settings/test' ),
82
+							'href' => rest_url('/wc/v4/settings/test'),
83 83
 						),
84 84
 					),
85 85
 				),
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 				'_links'      => array(
98 98
 					'options' => array(
99 99
 						array(
100
-							'href' => rest_url( '/wc/v4/settings/sub-test' ),
100
+							'href' => rest_url('/wc/v4/settings/sub-test'),
101 101
 						),
102 102
 					),
103 103
 				),
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 	 * @since 3.5.0
113 113
 	 */
114 114
 	public function test_get_groups_without_permission() {
115
-		wp_set_current_user( 0 );
115
+		wp_set_current_user(0);
116 116
 
117
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings' ) );
118
-		$this->assertEquals( 401, $response->get_status() );
117
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings'));
118
+		$this->assertEquals(401, $response->get_status());
119 119
 	}
120 120
 
121 121
 	/**
@@ -125,10 +125,10 @@  discard block
 block discarded – undo
125 125
 	 * @covers WC_Rest_Settings_Controller::get_items
126 126
 	 */
127 127
 	public function test_get_groups_none_registered() {
128
-		remove_all_filters( 'woocommerce_settings_groups' );
128
+		remove_all_filters('woocommerce_settings_groups');
129 129
 
130
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings' ) );
131
-		$this->assertEquals( 500, $response->get_status() );
130
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings'));
131
+		$this->assertEquals(500, $response->get_status());
132 132
 
133 133
 		SettingsHelper::register();
134 134
 	}
@@ -139,16 +139,16 @@  discard block
 block discarded – undo
139 139
 	 * @since 3.5.0
140 140
 	 */
141 141
 	public function test_get_group_schema() {
142
-		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings' );
143
-		$response   = $this->server->dispatch( $request );
142
+		$request    = new WP_REST_Request('OPTIONS', '/wc/v4/settings');
143
+		$response   = $this->server->dispatch($request);
144 144
 		$data       = $response->get_data();
145 145
 		$properties = $data['schema']['properties'];
146
-		$this->assertEquals( 5, count( $properties ) );
147
-		$this->assertArrayHasKey( 'id', $properties );
148
-		$this->assertArrayHasKey( 'parent_id', $properties );
149
-		$this->assertArrayHasKey( 'label', $properties );
150
-		$this->assertArrayHasKey( 'description', $properties );
151
-		$this->assertArrayHasKey( 'sub_groups', $properties );
146
+		$this->assertEquals(5, count($properties));
147
+		$this->assertArrayHasKey('id', $properties);
148
+		$this->assertArrayHasKey('parent_id', $properties);
149
+		$this->assertArrayHasKey('label', $properties);
150
+		$this->assertArrayHasKey('description', $properties);
151
+		$this->assertArrayHasKey('sub_groups', $properties);
152 152
 	}
153 153
 
154 154
 	/**
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
 	 * @since 3.5.0
158 158
 	 */
159 159
 	public function test_get_setting_schema() {
160
-		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/settings/test/woocommerce_shop_page_display' );
161
-		$response   = $this->server->dispatch( $request );
160
+		$request    = new WP_REST_Request('OPTIONS', '/wc/v4/settings/test/woocommerce_shop_page_display');
161
+		$response   = $this->server->dispatch($request);
162 162
 		$data       = $response->get_data();
163 163
 		$properties = $data['schema']['properties'];
164
-		$this->assertEquals( 10, count( $properties ) );
165
-		$this->assertArrayHasKey( 'id', $properties );
166
-		$this->assertArrayHasKey( 'label', $properties );
167
-		$this->assertArrayHasKey( 'description', $properties );
168
-		$this->assertArrayHasKey( 'value', $properties );
169
-		$this->assertArrayHasKey( 'default', $properties );
170
-		$this->assertArrayHasKey( 'tip', $properties );
171
-		$this->assertArrayHasKey( 'placeholder', $properties );
172
-		$this->assertArrayHasKey( 'type', $properties );
173
-		$this->assertArrayHasKey( 'options', $properties );
174
-		$this->assertArrayHasKey( 'group_id', $properties );
164
+		$this->assertEquals(10, count($properties));
165
+		$this->assertArrayHasKey('id', $properties);
166
+		$this->assertArrayHasKey('label', $properties);
167
+		$this->assertArrayHasKey('description', $properties);
168
+		$this->assertArrayHasKey('value', $properties);
169
+		$this->assertArrayHasKey('default', $properties);
170
+		$this->assertArrayHasKey('tip', $properties);
171
+		$this->assertArrayHasKey('placeholder', $properties);
172
+		$this->assertArrayHasKey('type', $properties);
173
+		$this->assertArrayHasKey('options', $properties);
174
+		$this->assertArrayHasKey('group_id', $properties);
175 175
 	}
176 176
 
177 177
 	/**
@@ -181,23 +181,23 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	public function test_get_group() {
183 183
 		// test route callback receiving an empty group id
184
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/' ) );
185
-		$this->assertEquals( 404, $response->get_status() );
184
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/'));
185
+		$this->assertEquals(404, $response->get_status());
186 186
 
187 187
 		// test getting a group that does not exist
188
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/not-real' ) );
189
-		$this->assertEquals( 404, $response->get_status() );
188
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/not-real'));
189
+		$this->assertEquals(404, $response->get_status());
190 190
 
191 191
 		// test getting the 'invalid' group
192
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/invalid' ) );
193
-		$this->assertEquals( 404, $response->get_status() );
192
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/invalid'));
193
+		$this->assertEquals(404, $response->get_status());
194 194
 
195 195
 		// test getting a valid group with settings attached to it
196
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) );
196
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test'));
197 197
 		$data     = $response->get_data();
198
-		$this->assertEquals( 1, count( $data ) );
199
-		$this->assertEquals( 'woocommerce_shop_page_display', $data[0]['id'] );
200
-		$this->assertEmpty( $data[0]['value'] );
198
+		$this->assertEquals(1, count($data));
199
+		$this->assertEquals('woocommerce_shop_page_display', $data[0]['id']);
200
+		$this->assertEmpty($data[0]['value']);
201 201
 	}
202 202
 
203 203
 	/**
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 * @since 3.5.0
207 207
 	 */
208 208
 	public function test_get_group_without_permission() {
209
-		wp_set_current_user( 0 );
209
+		wp_set_current_user(0);
210 210
 
211
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/coupon-data' ) );
212
-		$this->assertEquals( 401, $response->get_status() );
211
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/coupon-data'));
212
+		$this->assertEquals(401, $response->get_status());
213 213
 	}
214 214
 
215 215
 	/**
@@ -219,46 +219,46 @@  discard block
 block discarded – undo
219 219
 	 */
220 220
 	public function test_update_setting() {
221 221
 		// test defaults first
222
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/woocommerce_shop_page_display' ) );
222
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test/woocommerce_shop_page_display'));
223 223
 		$data     = $response->get_data();
224
-		$this->assertEquals( '', $data['value'] );
224
+		$this->assertEquals('', $data['value']);
225 225
 
226 226
 		// test updating shop display setting
227
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) );
227
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display'));
228 228
 		$request->set_body_params(
229 229
 			array(
230 230
 				'value' => 'both',
231 231
 			)
232 232
 		);
233
-		$response = $this->server->dispatch( $request );
233
+		$response = $this->server->dispatch($request);
234 234
 		$data     = $response->get_data();
235 235
 
236
-		$this->assertEquals( 'both', $data['value'] );
237
-		$this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) );
236
+		$this->assertEquals('both', $data['value']);
237
+		$this->assertEquals('both', get_option('woocommerce_shop_page_display'));
238 238
 
239
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) );
239
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display'));
240 240
 		$request->set_body_params(
241 241
 			array(
242 242
 				'value' => 'subcategories',
243 243
 			)
244 244
 		);
245
-		$response = $this->server->dispatch( $request );
245
+		$response = $this->server->dispatch($request);
246 246
 		$data     = $response->get_data();
247 247
 
248
-		$this->assertEquals( 'subcategories', $data['value'] );
249
-		$this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) );
248
+		$this->assertEquals('subcategories', $data['value']);
249
+		$this->assertEquals('subcategories', get_option('woocommerce_shop_page_display'));
250 250
 
251
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) );
251
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display'));
252 252
 		$request->set_body_params(
253 253
 			array(
254 254
 				'value' => '',
255 255
 			)
256 256
 		);
257
-		$response = $this->server->dispatch( $request );
257
+		$response = $this->server->dispatch($request);
258 258
 		$data     = $response->get_data();
259 259
 
260
-		$this->assertEquals( '', $data['value'] );
261
-		$this->assertEquals( '', get_option( 'woocommerce_shop_page_display' ) );
260
+		$this->assertEquals('', $data['value']);
261
+		$this->assertEquals('', get_option('woocommerce_shop_page_display'));
262 262
 	}
263 263
 
264 264
 	/**
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	public function test_update_settings() {
270 270
 		// test defaults first
271
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test' ) );
271
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test'));
272 272
 		$data     = $response->get_data();
273
-		$this->assertEquals( '', $data[0]['value'] );
273
+		$this->assertEquals('', $data[0]['value']);
274 274
 
275 275
 		// test setting both at once
276
-		$request = new WP_REST_Request( 'POST', '/wc/v4/settings/test/batch' );
276
+		$request = new WP_REST_Request('POST', '/wc/v4/settings/test/batch');
277 277
 		$request->set_body_params(
278 278
 			array(
279 279
 				'update' => array(
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 				),
285 285
 			)
286 286
 		);
287
-		$response = $this->server->dispatch( $request );
287
+		$response = $this->server->dispatch($request);
288 288
 		$data     = $response->get_data();
289 289
 
290
-		$this->assertEquals( 'both', $data['update'][0]['value'] );
291
-		$this->assertEquals( 'both', get_option( 'woocommerce_shop_page_display' ) );
290
+		$this->assertEquals('both', $data['update'][0]['value']);
291
+		$this->assertEquals('both', get_option('woocommerce_shop_page_display'));
292 292
 
293 293
 		// test updating one, but making sure the other value stays the same
294
-		$request = new WP_REST_Request( 'POST', '/wc/v4/settings/test/batch' );
294
+		$request = new WP_REST_Request('POST', '/wc/v4/settings/test/batch');
295 295
 		$request->set_body_params(
296 296
 			array(
297 297
 				'update' => array(
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 				),
303 303
 			)
304 304
 		);
305
-		$response = $this->server->dispatch( $request );
305
+		$response = $this->server->dispatch($request);
306 306
 		$data     = $response->get_data();
307
-		$this->assertEquals( 'subcategories', $data['update'][0]['value'] );
308
-		$this->assertEquals( 'subcategories', get_option( 'woocommerce_shop_page_display' ) );
307
+		$this->assertEquals('subcategories', $data['update'][0]['value']);
308
+		$this->assertEquals('subcategories', get_option('woocommerce_shop_page_display'));
309 309
 	}
310 310
 
311 311
 	/**
@@ -315,26 +315,26 @@  discard block
 block discarded – undo
315 315
 	 */
316 316
 	public function test_get_setting() {
317 317
 		// test getting an invalid setting from a group that does not exist
318
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/not-real/woocommerce_shop_page_display' ) );
318
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/not-real/woocommerce_shop_page_display'));
319 319
 		$data     = $response->get_data();
320
-		$this->assertEquals( 404, $response->get_status() );
320
+		$this->assertEquals(404, $response->get_status());
321 321
 
322 322
 		// test getting an invalid setting from a group that does exist
323
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/invalid/invalid' ) );
323
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/invalid/invalid'));
324 324
 		$data     = $response->get_data();
325
-		$this->assertEquals( 404, $response->get_status() );
325
+		$this->assertEquals(404, $response->get_status());
326 326
 
327 327
 		// test getting a valid setting
328
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/woocommerce_shop_page_display' ) );
328
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test/woocommerce_shop_page_display'));
329 329
 		$data     = $response->get_data();
330 330
 
331
-		$this->assertEquals( 200, $response->get_status() );
331
+		$this->assertEquals(200, $response->get_status());
332 332
 
333
-		$this->assertEquals( 'woocommerce_shop_page_display', $data['id'] );
334
-		$this->assertEquals( 'Shop page display', $data['label'] );
335
-		$this->assertEquals( '', $data['default'] );
336
-		$this->assertEquals( 'select', $data['type'] );
337
-		$this->assertEquals( '', $data['value'] );
333
+		$this->assertEquals('woocommerce_shop_page_display', $data['id']);
334
+		$this->assertEquals('Shop page display', $data['label']);
335
+		$this->assertEquals('', $data['default']);
336
+		$this->assertEquals('select', $data['type']);
337
+		$this->assertEquals('', $data['value']);
338 338
 	}
339 339
 
340 340
 	/**
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
 	 * @since 3.5.0
344 344
 	 */
345 345
 	public function test_get_setting_without_permission() {
346
-		wp_set_current_user( 0 );
346
+		wp_set_current_user(0);
347 347
 
348
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/woocommerce_shop_page_display' ) );
349
-		$this->assertEquals( 401, $response->get_status() );
348
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test/woocommerce_shop_page_display'));
349
+		$this->assertEquals(401, $response->get_status());
350 350
 	}
351 351
 
352 352
 	/**
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @since 3.5.0
356 356
 	 */
357 357
 	public function test_get_setting_empty_setting_id() {
358
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/' ) );
359
-		$this->assertEquals( 404, $response->get_status() );
358
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test/'));
359
+		$this->assertEquals(404, $response->get_status());
360 360
 	}
361 361
 
362 362
 	/**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @since 3.5.0
366 366
 	 */
367 367
 	public function test_get_setting_invalid_setting_id() {
368
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/test/invalid' ) );
369
-		$this->assertEquals( 404, $response->get_status() );
368
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/test/invalid'));
369
+		$this->assertEquals(404, $response->get_status());
370 370
 	}
371 371
 
372 372
 	/**
@@ -376,21 +376,21 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function test_get_setting_invalid_setting_type() {
378 378
 		// $controller = $this->getMock( 'WC_Rest_Setting_Options_Controller', array( 'get_group_settings', 'is_setting_type_valid' ) );
379
-		$controller = $this->getMockBuilder( 'WC_Rest_Setting_Options_Controller' )->setMethods( array( 'get_group_settings', 'is_setting_type_valid' ) )->getMock();
379
+		$controller = $this->getMockBuilder('WC_Rest_Setting_Options_Controller')->setMethods(array('get_group_settings', 'is_setting_type_valid'))->getMock();
380 380
 
381 381
 		$controller
382
-			->expects( $this->any() )
383
-			->method( 'get_group_settings' )
384
-			->will( $this->returnValue( SettingsHelper::register_test_settings( array() ) ) );
382
+			->expects($this->any())
383
+			->method('get_group_settings')
384
+			->will($this->returnValue(SettingsHelper::register_test_settings(array())));
385 385
 
386 386
 		$controller
387
-			->expects( $this->any() )
388
-			->method( 'is_setting_type_valid' )
389
-			->will( $this->returnValue( false ) );
387
+			->expects($this->any())
388
+			->method('is_setting_type_valid')
389
+			->will($this->returnValue(false));
390 390
 
391
-		$result = $controller->get_setting( 'test', 'woocommerce_shop_page_display' );
391
+		$result = $controller->get_setting('test', 'woocommerce_shop_page_display');
392 392
 
393
-		$this->assertIsWPError( $result );
393
+		$this->assertIsWPError($result);
394 394
 	}
395 395
 
396 396
 	/**
@@ -399,16 +399,16 @@  discard block
 block discarded – undo
399 399
 	 * @since 3.5.0
400 400
 	 */
401 401
 	public function test_update_setting_without_permission() {
402
-		wp_set_current_user( 0 );
402
+		wp_set_current_user(0);
403 403
 
404
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display' ) );
404
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'test', 'woocommerce_shop_page_display'));
405 405
 		$request->set_body_params(
406 406
 			array(
407 407
 				'value' => 'subcategories',
408 408
 			)
409 409
 		);
410
-		$response = $this->server->dispatch( $request );
411
-		$this->assertEquals( 401, $response->get_status() );
410
+		$response = $this->server->dispatch($request);
411
+		$this->assertEquals(401, $response->get_status());
412 412
 	}
413 413
 
414 414
 
@@ -418,9 +418,9 @@  discard block
 block discarded – undo
418 418
 	 * @since 3.5.0
419 419
 	 */
420 420
 	public function test_update_settings_without_permission() {
421
-		wp_set_current_user( 0 );
421
+		wp_set_current_user(0);
422 422
 
423
-		$request = new WP_REST_Request( 'POST', '/wc/v4/settings/test/batch' );
423
+		$request = new WP_REST_Request('POST', '/wc/v4/settings/test/batch');
424 424
 		$request->set_body_params(
425 425
 			array(
426 426
 				'update' => array(
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 				),
432 432
 			)
433 433
 		);
434
-		$response = $this->server->dispatch( $request );
435
-		$this->assertEquals( 401, $response->get_status() );
434
+		$response = $this->server->dispatch($request);
435
+		$this->assertEquals(401, $response->get_status());
436 436
 	}
437 437
 
438 438
 	/**
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
 	 * @covers WC_Rest_Setting_Options_Controller::update_item
443 443
 	 */
444 444
 	public function test_update_setting_bad_setting_id() {
445
-		$request = new WP_REST_Request( 'PUT', '/wc/v4/settings/test/invalid' );
445
+		$request = new WP_REST_Request('PUT', '/wc/v4/settings/test/invalid');
446 446
 		$request->set_body_params(
447 447
 			array(
448 448
 				'value' => 'test',
449 449
 			)
450 450
 		);
451
-		$response = $this->server->dispatch( $request );
452
-		$this->assertEquals( 404, $response->get_status() );
451
+		$response = $this->server->dispatch($request);
452
+		$this->assertEquals(404, $response->get_status());
453 453
 	}
454 454
 
455 455
 	/**
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 	 */
460 460
 	public function test_classic_settings() {
461 461
 		// Make sure the group is properly registered
462
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/products' ) );
462
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/products'));
463 463
 		$data     = $response->get_data();
464
-		$this->assertTrue( is_array( $data ) );
464
+		$this->assertTrue(is_array($data));
465 465
 		$this->assertContains(
466 466
 			array(
467 467
 				'id'          => 'woocommerce_downloads_require_login',
@@ -474,12 +474,12 @@  discard block
 block discarded – undo
474 474
 				'_links'      => array(
475 475
 					'self'       => array(
476 476
 						array(
477
-							'href' => rest_url( '/wc/v4/settings/products/woocommerce_downloads_require_login' ),
477
+							'href' => rest_url('/wc/v4/settings/products/woocommerce_downloads_require_login'),
478 478
 						),
479 479
 					),
480 480
 					'collection' => array(
481 481
 						array(
482
-							'href' => rest_url( '/wc/v4/settings/products' ),
482
+							'href' => rest_url('/wc/v4/settings/products'),
483 483
 						),
484 484
 					),
485 485
 				),
@@ -488,23 +488,23 @@  discard block
 block discarded – undo
488 488
 		);
489 489
 
490 490
 		// test get single
491
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/products/woocommerce_dimension_unit' ) );
491
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/products/woocommerce_dimension_unit'));
492 492
 		$data     = $response->get_data();
493 493
 
494
-		$this->assertEquals( 'cm', $data['default'] );
494
+		$this->assertEquals('cm', $data['default']);
495 495
 
496 496
 		// test update
497
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_dimension_unit' ) );
497
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'products', 'woocommerce_dimension_unit'));
498 498
 		$request->set_body_params(
499 499
 			array(
500 500
 				'value' => 'yd',
501 501
 			)
502 502
 		);
503
-		$response = $this->server->dispatch( $request );
503
+		$response = $this->server->dispatch($request);
504 504
 		$data     = $response->get_data();
505 505
 
506
-		$this->assertEquals( 'yd', $data['value'] );
507
-		$this->assertEquals( 'yd', get_option( 'woocommerce_dimension_unit' ) );
506
+		$this->assertEquals('yd', $data['value']);
507
+		$this->assertEquals('yd', get_option('woocommerce_dimension_unit'));
508 508
 	}
509 509
 
510 510
 	/**
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
 	 * @since 3.5.0
514 514
 	 */
515 515
 	public function test_email_settings() {
516
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/email_new_order' ) );
516
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/email_new_order'));
517 517
 		$settings = $response->get_data();
518 518
 
519
-		$this->assertEquals( 200, $response->get_status() );
519
+		$this->assertEquals(200, $response->get_status());
520 520
 
521 521
 		$this->assertContains(
522 522
 			array(
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
 				'_links'      => array(
531 531
 					'self'       => array(
532 532
 						array(
533
-							'href' => rest_url( '/wc/v4/settings/email_new_order/recipient' ),
533
+							'href' => rest_url('/wc/v4/settings/email_new_order/recipient'),
534 534
 						),
535 535
 					),
536 536
 					'collection' => array(
537 537
 						array(
538
-							'href' => rest_url( '/wc/v4/settings/email_new_order' ),
538
+							'href' => rest_url('/wc/v4/settings/email_new_order'),
539 539
 						),
540 540
 					),
541 541
 				),
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 		);
545 545
 
546 546
 		// test get single
547
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/email_new_order/subject' ) );
547
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/email_new_order/subject'));
548 548
 		$setting  = $response->get_data();
549 549
 
550 550
 		$this->assertEquals(
@@ -562,13 +562,13 @@  discard block
 block discarded – undo
562 562
 		);
563 563
 
564 564
 		// test update
565
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_new_order', 'subject' ) );
565
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'email_new_order', 'subject'));
566 566
 		$request->set_body_params(
567 567
 			array(
568 568
 				'value' => 'This is my subject',
569 569
 			)
570 570
 		);
571
-		$response = $this->server->dispatch( $request );
571
+		$response = $this->server->dispatch($request);
572 572
 		$setting  = $response->get_data();
573 573
 
574 574
 		$this->assertEquals(
@@ -586,29 +586,29 @@  discard block
 block discarded – undo
586 586
 		);
587 587
 
588 588
 		// test updating another subject and making sure it works with a "similar" id
589
-		$request  = new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject' ) );
590
-		$response = $this->server->dispatch( $request );
589
+		$request  = new WP_REST_Request('GET', sprintf('/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject'));
590
+		$response = $this->server->dispatch($request);
591 591
 		$setting  = $response->get_data();
592 592
 
593
-		$this->assertEmpty( $setting['value'] );
593
+		$this->assertEmpty($setting['value']);
594 594
 
595 595
 		// test update
596
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject' ) );
596
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'email_customer_new_account', 'subject'));
597 597
 		$request->set_body_params(
598 598
 			array(
599 599
 				'value' => 'This is my new subject',
600 600
 			)
601 601
 		);
602
-		$response = $this->server->dispatch( $request );
602
+		$response = $this->server->dispatch($request);
603 603
 		$setting  = $response->get_data();
604 604
 
605
-		$this->assertEquals( 'This is my new subject', $setting['value'] );
605
+		$this->assertEquals('This is my new subject', $setting['value']);
606 606
 
607 607
 		// make sure the other is what we left it
608
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/email_new_order/subject' ) );
608
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/email_new_order/subject'));
609 609
 		$setting  = $response->get_data();
610 610
 
611
-		$this->assertEquals( 'This is my subject', $setting['value'] );
611
+		$this->assertEquals('This is my subject', $setting['value']);
612 612
 	}
613 613
 
614 614
 	/**
@@ -618,34 +618,34 @@  discard block
 block discarded – undo
618 618
 	 */
619 619
 	public function test_validation_checkbox() {
620 620
 		// test bogus value
621
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled' ) );
621
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled'));
622 622
 		$request->set_body_params(
623 623
 			array(
624 624
 				'value' => 'not_yes_or_no',
625 625
 			)
626 626
 		);
627
-		$response = $this->server->dispatch( $request );
628
-		$this->assertEquals( 400, $response->get_status() );
627
+		$response = $this->server->dispatch($request);
628
+		$this->assertEquals(400, $response->get_status());
629 629
 
630 630
 		// test yes
631
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled' ) );
631
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled'));
632 632
 		$request->set_body_params(
633 633
 			array(
634 634
 				'value' => 'yes',
635 635
 			)
636 636
 		);
637
-		$response = $this->server->dispatch( $request );
638
-		$this->assertEquals( 200, $response->get_status() );
637
+		$response = $this->server->dispatch($request);
638
+		$this->assertEquals(200, $response->get_status());
639 639
 
640 640
 		// test no
641
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled' ) );
641
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'email_cancelled_order', 'enabled'));
642 642
 		$request->set_body_params(
643 643
 			array(
644 644
 				'value' => 'no',
645 645
 			)
646 646
 		);
647
-		$response = $this->server->dispatch( $request );
648
-		$this->assertEquals( 200, $response->get_status() );
647
+		$response = $this->server->dispatch($request);
648
+		$this->assertEquals(200, $response->get_status());
649 649
 	}
650 650
 
651 651
 	/**
@@ -655,24 +655,24 @@  discard block
 block discarded – undo
655 655
 	 */
656 656
 	public function test_validation_radio() {
657 657
 		// not a valid option
658
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'shipping', 'woocommerce_ship_to_destination' ) );
658
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'shipping', 'woocommerce_ship_to_destination'));
659 659
 		$request->set_body_params(
660 660
 			array(
661 661
 				'value' => 'billing2',
662 662
 			)
663 663
 		);
664
-		$response = $this->server->dispatch( $request );
665
-		$this->assertEquals( 400, $response->get_status() );
664
+		$response = $this->server->dispatch($request);
665
+		$this->assertEquals(400, $response->get_status());
666 666
 
667 667
 		// valid
668
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'shipping', 'woocommerce_ship_to_destination' ) );
668
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'shipping', 'woocommerce_ship_to_destination'));
669 669
 		$request->set_body_params(
670 670
 			array(
671 671
 				'value' => 'billing',
672 672
 			)
673 673
 		);
674
-		$response = $this->server->dispatch( $request );
675
-		$this->assertEquals( 200, $response->get_status() );
674
+		$response = $this->server->dispatch($request);
675
+		$this->assertEquals(200, $response->get_status());
676 676
 	}
677 677
 
678 678
 	/**
@@ -681,19 +681,19 @@  discard block
 block discarded – undo
681 681
 	 * @since 3.5.0
682 682
 	 */
683 683
 	public function test_validation_multiselect() {
684
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) ) );
684
+		$response = $this->server->dispatch(new WP_REST_Request('GET', sprintf('/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries')));
685 685
 		$setting  = $response->get_data();
686
-		$this->assertEmpty( $setting['value'] );
686
+		$this->assertEmpty($setting['value']);
687 687
 
688
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries' ) );
688
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'general', 'woocommerce_specific_allowed_countries'));
689 689
 		$request->set_body_params(
690 690
 			array(
691
-				'value' => array( 'AX', 'DZ', 'MMM' ),
691
+				'value' => array('AX', 'DZ', 'MMM'),
692 692
 			)
693 693
 		);
694
-		$response = $this->server->dispatch( $request );
694
+		$response = $this->server->dispatch($request);
695 695
 		$setting  = $response->get_data();
696
-		$this->assertEquals( array( 'AX', 'DZ' ), $setting['value'] );
696
+		$this->assertEquals(array('AX', 'DZ'), $setting['value']);
697 697
 	}
698 698
 
699 699
 	/**
@@ -702,30 +702,30 @@  discard block
 block discarded – undo
702 702
 	 * @since 3.5.0
703 703
 	 */
704 704
 	public function test_validation_select() {
705
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) ) );
705
+		$response = $this->server->dispatch(new WP_REST_Request('GET', sprintf('/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit')));
706 706
 		$setting  = $response->get_data();
707
-		$this->assertEquals( 'kg', $setting['value'] );
707
+		$this->assertEquals('kg', $setting['value']);
708 708
 
709 709
 		// invalid
710
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) );
710
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit'));
711 711
 		$request->set_body_params(
712 712
 			array(
713 713
 				'value' => 'pounds', // invalid, should be lbs
714 714
 			)
715 715
 		);
716
-		$response = $this->server->dispatch( $request );
717
-		$this->assertEquals( 400, $response->get_status() );
716
+		$response = $this->server->dispatch($request);
717
+		$this->assertEquals(400, $response->get_status());
718 718
 
719 719
 		// valid
720
-		$request = new WP_REST_Request( 'PUT', sprintf( '/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit' ) );
720
+		$request = new WP_REST_Request('PUT', sprintf('/wc/v4/settings/%s/%s', 'products', 'woocommerce_weight_unit'));
721 721
 		$request->set_body_params(
722 722
 			array(
723 723
 				'value' => 'lbs', // invalid, should be lbs
724 724
 			)
725 725
 		);
726
-		$response = $this->server->dispatch( $request );
726
+		$response = $this->server->dispatch($request);
727 727
 		$setting  = $response->get_data();
728
-		$this->assertEquals( 'lbs', $setting['value'] );
728
+		$this->assertEquals('lbs', $setting['value']);
729 729
 	}
730 730
 
731 731
 	/**
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
 	 * @since 3.5.0
737 737
 	 */
738 738
 	public function test_woocommerce_default_country() {
739
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_default_country' ) );
739
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/general/woocommerce_default_country'));
740 740
 		$setting  = $response->get_data();
741 741
 
742
-		$this->assertEquals( 'select', $setting['type'] );
743
-		$this->assertArrayHasKey( 'GB', $setting['options'] );
744
-		$this->assertArrayHasKey( 'US:OR', $setting['options'] );
742
+		$this->assertEquals('select', $setting['type']);
743
+		$this->assertArrayHasKey('GB', $setting['options']);
744
+		$this->assertArrayHasKey('US:OR', $setting['options']);
745 745
 	}
746 746
 
747 747
 	/**
@@ -750,33 +750,33 @@  discard block
 block discarded – undo
750 750
 	 * @since 3.5.0
751 751
 	 */
752 752
 	public function test_woocommerce_store_address() {
753
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address' ) );
753
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/general/woocommerce_store_address'));
754 754
 		$setting  = $response->get_data();
755
-		$this->assertEquals( 'text', $setting['type'] );
755
+		$this->assertEquals('text', $setting['type']);
756 756
 
757 757
 		// Repalce the old value with something uniquely new
758 758
 		$old_value = $setting['value'];
759
-		$new_value = $old_value . ' ' . rand( 1000, 9999 );
760
-		$request   = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' );
759
+		$new_value = $old_value . ' ' . rand(1000, 9999);
760
+		$request   = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_address');
761 761
 		$request->set_body_params(
762 762
 			array(
763 763
 				'value' => $new_value,
764 764
 			)
765 765
 		);
766
-		$response = $this->server->dispatch( $request );
766
+		$response = $this->server->dispatch($request);
767 767
 		$setting  = $response->get_data();
768
-		$this->assertEquals( $new_value, $setting['value'] );
768
+		$this->assertEquals($new_value, $setting['value']);
769 769
 
770 770
 		// Put the original value back
771
-		$request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address' );
771
+		$request = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_address');
772 772
 		$request->set_body_params(
773 773
 			array(
774 774
 				'value' => $old_value,
775 775
 			)
776 776
 		);
777
-		$response = $this->server->dispatch( $request );
777
+		$response = $this->server->dispatch($request);
778 778
 		$setting  = $response->get_data();
779
-		$this->assertEquals( $old_value, $setting['value'] );
779
+		$this->assertEquals($old_value, $setting['value']);
780 780
 	}
781 781
 
782 782
 	/**
@@ -785,33 +785,33 @@  discard block
 block discarded – undo
785 785
 	 * @since 3.5.0
786 786
 	 */
787 787
 	public function test_woocommerce_store_address_2() {
788
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_address_2' ) );
788
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/general/woocommerce_store_address_2'));
789 789
 		$setting  = $response->get_data();
790
-		$this->assertEquals( 'text', $setting['type'] );
790
+		$this->assertEquals('text', $setting['type']);
791 791
 
792 792
 		// Repalce the old value with something uniquely new
793 793
 		$old_value = $setting['value'];
794
-		$new_value = $old_value . ' ' . rand( 1000, 9999 );
795
-		$request   = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' );
794
+		$new_value = $old_value . ' ' . rand(1000, 9999);
795
+		$request   = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_address_2');
796 796
 		$request->set_body_params(
797 797
 			array(
798 798
 				'value' => $new_value,
799 799
 			)
800 800
 		);
801
-		$response = $this->server->dispatch( $request );
801
+		$response = $this->server->dispatch($request);
802 802
 		$setting  = $response->get_data();
803
-		$this->assertEquals( $new_value, $setting['value'] );
803
+		$this->assertEquals($new_value, $setting['value']);
804 804
 
805 805
 		// Put the original value back
806
-		$request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_address_2' );
806
+		$request = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_address_2');
807 807
 		$request->set_body_params(
808 808
 			array(
809 809
 				'value' => $old_value,
810 810
 			)
811 811
 		);
812
-		$response = $this->server->dispatch( $request );
812
+		$response = $this->server->dispatch($request);
813 813
 		$setting  = $response->get_data();
814
-		$this->assertEquals( $old_value, $setting['value'] );
814
+		$this->assertEquals($old_value, $setting['value']);
815 815
 	}
816 816
 
817 817
 	/**
@@ -820,33 +820,33 @@  discard block
 block discarded – undo
820 820
 	 * @since 3.5.0
821 821
 	 */
822 822
 	public function test_woocommerce_store_city() {
823
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_city' ) );
823
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/general/woocommerce_store_city'));
824 824
 		$setting  = $response->get_data();
825
-		$this->assertEquals( 'text', $setting['type'] );
825
+		$this->assertEquals('text', $setting['type']);
826 826
 
827 827
 		// Repalce the old value with something uniquely new
828 828
 		$old_value = $setting['value'];
829
-		$new_value = $old_value . ' ' . rand( 1000, 9999 );
830
-		$request   = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' );
829
+		$new_value = $old_value . ' ' . rand(1000, 9999);
830
+		$request   = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_city');
831 831
 		$request->set_body_params(
832 832
 			array(
833 833
 				'value' => $new_value,
834 834
 			)
835 835
 		);
836
-		$response = $this->server->dispatch( $request );
836
+		$response = $this->server->dispatch($request);
837 837
 		$setting  = $response->get_data();
838
-		$this->assertEquals( $new_value, $setting['value'] );
838
+		$this->assertEquals($new_value, $setting['value']);
839 839
 
840 840
 		// Put the original value back
841
-		$request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_city' );
841
+		$request = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_city');
842 842
 		$request->set_body_params(
843 843
 			array(
844 844
 				'value' => $old_value,
845 845
 			)
846 846
 		);
847
-		$response = $this->server->dispatch( $request );
847
+		$response = $this->server->dispatch($request);
848 848
 		$setting  = $response->get_data();
849
-		$this->assertEquals( $old_value, $setting['value'] );
849
+		$this->assertEquals($old_value, $setting['value']);
850 850
 	}
851 851
 
852 852
 	/**
@@ -855,32 +855,32 @@  discard block
 block discarded – undo
855 855
 	 * @since 3.5.0
856 856
 	 */
857 857
 	public function test_woocommerce_store_postcode() {
858
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/settings/general/woocommerce_store_postcode' ) );
858
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/settings/general/woocommerce_store_postcode'));
859 859
 		$setting  = $response->get_data();
860
-		$this->assertEquals( 'text', $setting['type'] );
860
+		$this->assertEquals('text', $setting['type']);
861 861
 
862 862
 		// Repalce the old value with something uniquely new
863 863
 		$old_value = $setting['value'];
864
-		$new_value = $old_value . ' ' . rand( 1000, 9999 );
865
-		$request   = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' );
864
+		$new_value = $old_value . ' ' . rand(1000, 9999);
865
+		$request   = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_postcode');
866 866
 		$request->set_body_params(
867 867
 			array(
868 868
 				'value' => $new_value,
869 869
 			)
870 870
 		);
871
-		$response = $this->server->dispatch( $request );
871
+		$response = $this->server->dispatch($request);
872 872
 		$setting  = $response->get_data();
873
-		$this->assertEquals( $new_value, $setting['value'] );
873
+		$this->assertEquals($new_value, $setting['value']);
874 874
 
875 875
 		// Put the original value back
876
-		$request = new WP_REST_Request( 'PUT', '/wc/v4/settings/general/woocommerce_store_postcode' );
876
+		$request = new WP_REST_Request('PUT', '/wc/v4/settings/general/woocommerce_store_postcode');
877 877
 		$request->set_body_params(
878 878
 			array(
879 879
 				'value' => $old_value,
880 880
 			)
881 881
 		);
882
-		$response = $this->server->dispatch( $request );
882
+		$response = $this->server->dispatch($request);
883 883
 		$setting  = $response->get_data();
884
-		$this->assertEquals( $old_value, $setting['value'] );
884
+		$this->assertEquals($old_value, $setting['value']);
885 885
 	}
886 886
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/ShippingMethods.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 namespace WooCommerce\RestApi\UnitTests\Tests\Version4;
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 use \WP_REST_Request;
14 14
 use \WC_REST_Unit_Test_Case;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param object $factory Factory object.
29 29
 	 */
30
-	public static function wpSetUpBeforeClass( $factory ) {
30
+	public static function wpSetUpBeforeClass($factory) {
31 31
 		self::$user = $factory->user->create(
32 32
 			array(
33 33
 				'role' => 'administrator',
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 */
41 41
 	public function setUp() {
42 42
 		parent::setUp();
43
-		wp_set_current_user( self::$user );
43
+		wp_set_current_user(self::$user);
44 44
 		$this->zones = array();
45 45
 	}
46 46
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function test_register_routes() {
53 53
 		$routes = $this->server->get_routes();
54
-		$this->assertArrayHasKey( '/wc/v4/shipping_methods', $routes );
55
-		$this->assertArrayHasKey( '/wc/v4/shipping_methods/(?P<id>[\w-]+)', $routes );
54
+		$this->assertArrayHasKey('/wc/v4/shipping_methods', $routes);
55
+		$this->assertArrayHasKey('/wc/v4/shipping_methods/(?P<id>[\w-]+)', $routes);
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 	 * @since 3.5.0
62 62
 	 */
63 63
 	public function test_get_shipping_methods() {
64
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/shipping_methods' ) );
64
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/shipping_methods'));
65 65
 		$methods  = $response->get_data();
66 66
 
67
-		$this->assertEquals( 200, $response->get_status() );
67
+		$this->assertEquals(200, $response->get_status());
68 68
 		$this->assertContains(
69 69
 			array(
70 70
 				'id'          => 'free_shipping',
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 				'_links'      => array(
74 74
 					'self'       => array(
75 75
 						array(
76
-							'href' => rest_url( '/wc/v4/shipping_methods/free_shipping' ),
76
+							'href' => rest_url('/wc/v4/shipping_methods/free_shipping'),
77 77
 						),
78 78
 					),
79 79
 					'collection' => array(
80 80
 						array(
81
-							'href' => rest_url( '/wc/v4/shipping_methods' ),
81
+							'href' => rest_url('/wc/v4/shipping_methods'),
82 82
 						),
83 83
 					),
84 84
 				),
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 	 * @since 3.5.0
94 94
 	 */
95 95
 	public function test_get_shipping_methods_without_permission() {
96
-		wp_set_current_user( 0 );
97
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/shipping_methods' ) );
98
-		$this->assertEquals( 401, $response->get_status() );
96
+		wp_set_current_user(0);
97
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/shipping_methods'));
98
+		$this->assertEquals(401, $response->get_status());
99 99
 	}
100 100
 
101 101
 	/**
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 * @since 3.5.0
105 105
 	 */
106 106
 	public function test_get_shipping_method() {
107
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/shipping_methods/local_pickup' ) );
107
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/shipping_methods/local_pickup'));
108 108
 		$method   = $response->get_data();
109 109
 
110
-		$this->assertEquals( 200, $response->get_status() );
110
+		$this->assertEquals(200, $response->get_status());
111 111
 		$this->assertEquals(
112 112
 			array(
113 113
 				'id'          => 'local_pickup',
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 	 * @since 3.5.0
125 125
 	 */
126 126
 	public function test_get_shipping_method_without_permission() {
127
-		wp_set_current_user( 0 );
127
+		wp_set_current_user(0);
128 128
 
129
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/shipping_methods/local_pickup' ) );
130
-		$this->assertEquals( 401, $response->get_status() );
129
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/shipping_methods/local_pickup'));
130
+		$this->assertEquals(401, $response->get_status());
131 131
 	}
132 132
 
133 133
 	/**
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 	 * @since 3.5.0
137 137
 	 */
138 138
 	public function test_get_shipping_method_invalid_id() {
139
-		$response = $this->server->dispatch( new WP_REST_Request( 'GET', '/wc/v4/shipping_methods/fake_method' ) );
140
-		$this->assertEquals( 404, $response->get_status() );
139
+		$response = $this->server->dispatch(new WP_REST_Request('GET', '/wc/v4/shipping_methods/fake_method'));
140
+		$this->assertEquals(404, $response->get_status());
141 141
 	}
142 142
 
143 143
 	/**
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 	 * @since 3.5.0
147 147
 	 */
148 148
 	public function test_shipping_method_schema() {
149
-		$request    = new WP_REST_Request( 'OPTIONS', '/wc/v4/shipping_methods' );
150
-		$response   = $this->server->dispatch( $request );
149
+		$request    = new WP_REST_Request('OPTIONS', '/wc/v4/shipping_methods');
150
+		$response   = $this->server->dispatch($request);
151 151
 		$data       = $response->get_data();
152 152
 		$properties = $data['schema']['properties'];
153 153
 
154
-		$this->assertEquals( 3, count( $properties ) );
155
-		$this->assertArrayHasKey( 'id', $properties );
156
-		$this->assertArrayHasKey( 'title', $properties );
157
-		$this->assertArrayHasKey( 'description', $properties );
154
+		$this->assertEquals(3, count($properties));
155
+		$this->assertArrayHasKey('id', $properties);
156
+		$this->assertArrayHasKey('title', $properties);
157
+		$this->assertArrayHasKey('description', $properties);
158 158
 	}
159 159
 }
Please login to merge, or discard this patch.
unit-tests/Tests/Version4/ProductReviews.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 namespace WooCommerce\RestApi\UnitTests\Tests\Version4;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 use \WooCommerce\RestApi\UnitTests\AbstractRestApiTest;
13 13
 use \WooCommerce\RestApi\UnitTests\Helpers\ProductHelper;
@@ -35,17 +35,17 @@  discard block
 block discarded – undo
35 35
 	 * @var array Keys are property names, values are supported context.
36 36
 	 */
37 37
 	protected $properties = [
38
-		'id'                   => array( 'view', 'edit' ),
39
-		'date_created'         => array( 'view', 'edit' ),
40
-		'date_created_gmt'     => array( 'view', 'edit' ),
41
-		'product_id'           => array( 'view', 'edit' ),
42
-		'status'               => array( 'view', 'edit' ),
43
-		'reviewer'             => array( 'view', 'edit' ),
44
-		'reviewer_email'       => array( 'view', 'edit' ),
45
-		'review'               => array( 'view', 'edit' ),
46
-		'rating'               => array( 'view', 'edit' ),
47
-		'verified'             => array( 'view', 'edit' ),
48
-		'reviewer_avatar_urls' => array( 'view', 'edit' ),
38
+		'id'                   => array('view', 'edit'),
39
+		'date_created'         => array('view', 'edit'),
40
+		'date_created_gmt'     => array('view', 'edit'),
41
+		'product_id'           => array('view', 'edit'),
42
+		'status'               => array('view', 'edit'),
43
+		'reviewer'             => array('view', 'edit'),
44
+		'reviewer_email'       => array('view', 'edit'),
45
+		'review'               => array('view', 'edit'),
46
+		'rating'               => array('view', 'edit'),
47
+		'verified'             => array('view', 'edit'),
48
+		'reviewer_avatar_urls' => array('view', 'edit'),
49 49
 	];
50 50
 
51 51
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 			'rating'         => '5',
62 62
 			'product_id'     => $product->get_id(),
63 63
 		];
64
-		$response = $this->do_request( '/wc/v4/products/reviews', 'POST', $data );
65
-		$this->assertExpectedResponse( $response, 201, $data );
64
+		$response = $this->do_request('/wc/v4/products/reviews', 'POST', $data);
65
+		$this->assertExpectedResponse($response, 201, $data);
66 66
 		$this->assertEquals(
67 67
 			array(
68 68
 				'id'                   => $response->data['id'],
@@ -86,20 +86,20 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function test_read() {
88 88
 		$product = ProductHelper::create_simple_product();
89
-		for ( $i = 0; $i < 10; $i++ ) {
90
-			$review_id = ProductHelper::create_product_review( $product->get_id() );
89
+		for ($i = 0; $i < 10; $i++) {
90
+			$review_id = ProductHelper::create_product_review($product->get_id());
91 91
 		}
92 92
 
93 93
 		// Invalid.
94
-		$response = $this->do_request( '/wc/v4/products/0/reviews' );
95
-		$this->assertExpectedResponse( $response, 404 );
94
+		$response = $this->do_request('/wc/v4/products/0/reviews');
95
+		$this->assertExpectedResponse($response, 404);
96 96
 
97 97
 		// Collections.
98
-		$response        = $this->do_request( '/wc/v4/products/reviews' );
98
+		$response        = $this->do_request('/wc/v4/products/reviews');
99 99
 		$product_reviews = $response->data;
100 100
 
101
-		$this->assertExpectedResponse( $response, 200 );
102
-		$this->assertEquals( 10, count( $product_reviews ) );
101
+		$this->assertExpectedResponse($response, 200);
102
+		$this->assertEquals(10, count($product_reviews));
103 103
 		$this->assertContains(
104 104
 			array(
105 105
 				'id'                   => $review_id,
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 				'_links'               => array(
117 117
 					'self'       => array(
118 118
 						array(
119
-							'href' => rest_url( '/wc/v4/products/reviews/' . $review_id ),
119
+							'href' => rest_url('/wc/v4/products/reviews/' . $review_id),
120 120
 						),
121 121
 					),
122 122
 					'collection' => array(
123 123
 						array(
124
-							'href' => rest_url( '/wc/v4/products/reviews' ),
124
+							'href' => rest_url('/wc/v4/products/reviews'),
125 125
 						),
126 126
 					),
127 127
 					'up'         => array(
128 128
 						array(
129 129
 							'embeddable' => true,
130
-							'href'       => rest_url( '/wc/v4/products/' . $product->get_id() ),
130
+							'href'       => rest_url('/wc/v4/products/' . $product->get_id()),
131 131
 						),
132 132
 					),
133 133
 				),
@@ -142,27 +142,27 @@  discard block
 block discarded – undo
142 142
 	 */
143 143
 	public function test_update() {
144 144
 		$product           = ProductHelper::create_simple_product();
145
-		$product_review_id = ProductHelper::create_product_review( $product->get_id() );
145
+		$product_review_id = ProductHelper::create_product_review($product->get_id());
146 146
 
147
-		$response          = $this->do_request( '/wc/v4/products/reviews/' . $product_review_id );
148
-		$this->assertEquals( 200, $response->status );
149
-		$this->assertEquals( "<p>Review content here</p>\n", $response->data['review'] );
150
-		$this->assertEquals( 'admin', $response->data['reviewer'] );
151
-		$this->assertEquals( '[email protected]', $response->data['reviewer_email'] );
152
-		$this->assertEquals( 0, $response->data['rating'] );
147
+		$response          = $this->do_request('/wc/v4/products/reviews/' . $product_review_id);
148
+		$this->assertEquals(200, $response->status);
149
+		$this->assertEquals("<p>Review content here</p>\n", $response->data['review']);
150
+		$this->assertEquals('admin', $response->data['reviewer']);
151
+		$this->assertEquals('[email protected]', $response->data['reviewer_email']);
152
+		$this->assertEquals(0, $response->data['rating']);
153 153
 
154
-		$data     = [
154
+		$data = [
155 155
 			'review'         => 'Hello world - updated.',
156 156
 			'reviewer'       => 'Justin',
157 157
 			'reviewer_email' => '[email protected]',
158 158
 			'rating'         => 3,
159 159
 		];
160
-		$response = $this->do_request( '/wc/v4/products/reviews/' . $product_review_id, 'PUT', $data );
160
+		$response = $this->do_request('/wc/v4/products/reviews/' . $product_review_id, 'PUT', $data);
161 161
 
162
-		$this->assertExpectedResponse( $response, 200, $data );
162
+		$this->assertExpectedResponse($response, 200, $data);
163 163
 
164
-		foreach ( $this->get_properties( 'view' ) as $property ) {
165
-			$this->assertArrayHasKey( $property, $response->data );
164
+		foreach ($this->get_properties('view') as $property) {
165
+			$this->assertArrayHasKey($property, $response->data);
166 166
 		}
167 167
 	}
168 168
 
@@ -172,23 +172,23 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function test_delete() {
174 174
 		// Invalid.
175
-		$result = $this->do_request( '/wc/v4/products/reviews/0', 'DELETE', [ 'force' => true ] );
176
-		$this->assertEquals( 404, $result->status );
175
+		$result = $this->do_request('/wc/v4/products/reviews/0', 'DELETE', ['force' => true]);
176
+		$this->assertEquals(404, $result->status);
177 177
 
178 178
 		// Valid.
179 179
 		$product           = ProductHelper::create_simple_product();
180
-		$product_review_id = ProductHelper::create_product_review( $product->get_id() );
181
-		$result            = $this->do_request( '/wc/v4/products/reviews/' . $product_review_id, 'DELETE', [ 'force' => true ] );
182
-		$this->assertEquals( 200, $result->status );
180
+		$product_review_id = ProductHelper::create_product_review($product->get_id());
181
+		$result            = $this->do_request('/wc/v4/products/reviews/' . $product_review_id, 'DELETE', ['force' => true]);
182
+		$this->assertEquals(200, $result->status);
183 183
 	}
184 184
 
185 185
 	/**
186 186
 	 * Test get/read using this method.
187 187
 	 */
188 188
 	public function test_guest_read() {
189
-		wp_set_current_user( 0 );
190
-		$result = $this->do_request( '/wc/v4/products/reviews' );
191
-		$this->assertEquals( 401, $result->status );
189
+		wp_set_current_user(0);
190
+		$result = $this->do_request('/wc/v4/products/reviews');
191
+		$this->assertEquals(401, $result->status);
192 192
 	}
193 193
 
194 194
 	/**
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public function test_get_product_review() {
200 200
 		$product           = ProductHelper::create_simple_product();
201
-		$product_review_id = ProductHelper::create_product_review( $product->get_id() );
201
+		$product_review_id = ProductHelper::create_product_review($product->get_id());
202 202
 
203
-		$response = $this->server->dispatch( new \WP_REST_Request( 'GET', '/wc/v4/products/reviews/' . $product_review_id ) );
203
+		$response = $this->server->dispatch(new \WP_REST_Request('GET', '/wc/v4/products/reviews/' . $product_review_id));
204 204
 		$data     = $response->get_data();
205 205
 
206
-		$this->assertEquals( 200, $response->get_status() );
206
+		$this->assertEquals(200, $response->get_status());
207 207
 		$this->assertEquals(
208 208
 			array(
209 209
 				'id'                   => $product_review_id,
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function test_get_product_review_invalid_id() {
231 231
 		$product  = ProductHelper::create_simple_product();
232
-		$response = $this->server->dispatch( new \WP_REST_Request( 'GET', '/wc/v4/products/reviews/0' ) );
233
-		$this->assertEquals( 404, $response->get_status() );
232
+		$response = $this->server->dispatch(new \WP_REST_Request('GET', '/wc/v4/products/reviews/0'));
233
+		$this->assertEquals(404, $response->get_status());
234 234
 	}
235 235
 
236 236
 	/**
@@ -242,43 +242,43 @@  discard block
 block discarded – undo
242 242
 		$product = ProductHelper::create_simple_product();
243 243
 
244 244
 		// missing review
245
-		$request = new \WP_REST_Request( 'POST', '/wc/v4/products/reviews' );
245
+		$request = new \WP_REST_Request('POST', '/wc/v4/products/reviews');
246 246
 		$request->set_body_params(
247 247
 			array(
248 248
 				'reviewer'       => 'Admin',
249 249
 				'reviewer_email' => '[email protected]',
250 250
 			)
251 251
 		);
252
-		$response = $this->server->dispatch( $request );
252
+		$response = $this->server->dispatch($request);
253 253
 		$data     = $response->get_data();
254 254
 
255
-		$this->assertEquals( 400, $response->get_status() );
255
+		$this->assertEquals(400, $response->get_status());
256 256
 
257 257
 		// Missing reviewer.
258
-		$request = new \WP_REST_Request( 'POST', '/wc/v4/products/reviews' );
258
+		$request = new \WP_REST_Request('POST', '/wc/v4/products/reviews');
259 259
 		$request->set_body_params(
260 260
 			array(
261 261
 				'review'         => 'Hello world.',
262 262
 				'reviewer_email' => '[email protected]',
263 263
 			)
264 264
 		);
265
-		$response = $this->server->dispatch( $request );
265
+		$response = $this->server->dispatch($request);
266 266
 		$data     = $response->get_data();
267 267
 
268
-		$this->assertEquals( 400, $response->get_status() );
268
+		$this->assertEquals(400, $response->get_status());
269 269
 
270 270
 		// missing reviewer_email
271
-		$request = new \WP_REST_Request( 'POST', '/wc/v4/products/reviews' );
271
+		$request = new \WP_REST_Request('POST', '/wc/v4/products/reviews');
272 272
 		$request->set_body_params(
273 273
 			array(
274 274
 				'review'   => 'Hello world.',
275 275
 				'reviewer' => 'Admin',
276 276
 			)
277 277
 		);
278
-		$response = $this->server->dispatch( $request );
278
+		$response = $this->server->dispatch($request);
279 279
 		$data     = $response->get_data();
280 280
 
281
-		$this->assertEquals( 400, $response->get_status() );
281
+		$this->assertEquals(400, $response->get_status());
282 282
 	}
283 283
 
284 284
 	/**
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 	 * @since 3.5.0
288 288
 	 */
289 289
 	public function test_update_product_review_without_permission() {
290
-		wp_set_current_user( 0 );
290
+		wp_set_current_user(0);
291 291
 		$product           = ProductHelper::create_simple_product();
292
-		$product_review_id = ProductHelper::create_product_review( $product->get_id() );
292
+		$product_review_id = ProductHelper::create_product_review($product->get_id());
293 293
 
294
-		$request = new \WP_REST_Request( 'PUT', '/wc/v4/products/reviews/' . $product_review_id );
294
+		$request = new \WP_REST_Request('PUT', '/wc/v4/products/reviews/' . $product_review_id);
295 295
 		$request->set_body_params(
296 296
 			array(
297 297
 				'review'         => 'Hello world.',
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
 				'reviewer_email' => '[email protected]',
300 300
 			)
301 301
 		);
302
-		$response = $this->server->dispatch( $request );
302
+		$response = $this->server->dispatch($request);
303 303
 		$data     = $response->get_data();
304 304
 
305
-		$this->assertEquals( 401, $response->get_status() );
305
+		$this->assertEquals(401, $response->get_status());
306 306
 	}
307 307
 
308 308
 	/**
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 	 * @since 3.5.0
312 312
 	 */
313 313
 	public function test_update_product_review_invalid_id() {
314
-		wp_set_current_user( $this->user );
314
+		wp_set_current_user($this->user);
315 315
 		$product = ProductHelper::create_simple_product();
316 316
 
317
-		$request = new \WP_REST_Request( 'PUT', '/wc/v4/products/reviews/0' );
317
+		$request = new \WP_REST_Request('PUT', '/wc/v4/products/reviews/0');
318 318
 		$request->set_body_params(
319 319
 			array(
320 320
 				'review'         => 'Hello world.',
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 				'reviewer_email' => '[email protected]',
323 323
 			)
324 324
 		);
325
-		$response = $this->server->dispatch( $request );
325
+		$response = $this->server->dispatch($request);
326 326
 		$data     = $response->get_data();
327 327
 
328
-		$this->assertEquals( 404, $response->get_status() );
328
+		$this->assertEquals(404, $response->get_status());
329 329
 	}
330 330
 
331 331
 	/**
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	 * @since 3.5.0
335 335
 	 */
336 336
 	public function test_delete_product_without_permission() {
337
-		wp_set_current_user( 0 );
337
+		wp_set_current_user(0);
338 338
 		$product           = ProductHelper::create_simple_product();
339
-		$product_review_id = ProductHelper::create_product_review( $product->get_id() );
339
+		$product_review_id = ProductHelper::create_product_review($product->get_id());
340 340
 
341
-		$request  = new \WP_REST_Request( 'DELETE', '/wc/v4/products/reviews/' . $product_review_id );
342
-		$response = $this->server->dispatch( $request );
341
+		$request  = new \WP_REST_Request('DELETE', '/wc/v4/products/reviews/' . $product_review_id);
342
+		$response = $this->server->dispatch($request);
343 343
 
344
-		$this->assertEquals( 401, $response->get_status() );
344
+		$this->assertEquals(401, $response->get_status());
345 345
 	}
346 346
 
347 347
 	/**
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	public function test_product_reviews_batch() {
353 353
 		$product = ProductHelper::create_simple_product();
354 354
 
355
-		$review_1_id = ProductHelper::create_product_review( $product->get_id() );
356
-		$review_2_id = ProductHelper::create_product_review( $product->get_id() );
357
-		$review_3_id = ProductHelper::create_product_review( $product->get_id() );
358
-		$review_4_id = ProductHelper::create_product_review( $product->get_id() );
355
+		$review_1_id = ProductHelper::create_product_review($product->get_id());
356
+		$review_2_id = ProductHelper::create_product_review($product->get_id());
357
+		$review_3_id = ProductHelper::create_product_review($product->get_id());
358
+		$review_4_id = ProductHelper::create_product_review($product->get_id());
359 359
 
360
-		$request = new \WP_REST_Request( 'POST', '/wc/v4/products/reviews/batch' );
360
+		$request = new \WP_REST_Request('POST', '/wc/v4/products/reviews/batch');
361 361
 		$request->set_body_params(
362 362
 			array(
363 363
 				'update' => array(
@@ -380,21 +380,21 @@  discard block
 block discarded – undo
380 380
 				),
381 381
 			)
382 382
 		);
383
-		$response = $this->server->dispatch( $request );
383
+		$response = $this->server->dispatch($request);
384 384
 		$data     = $response->get_data();
385 385
 
386
-		$this->assertEquals( 'Updated review.', $data['update'][0]['review'] );
387
-		$this->assertEquals( 'New review.', $data['create'][0]['review'] );
388
-		$this->assertEquals( $review_2_id, $data['delete'][0]['previous']['id'] );
389
-		$this->assertEquals( $review_3_id, $data['delete'][1]['previous']['id'] );
386
+		$this->assertEquals('Updated review.', $data['update'][0]['review']);
387
+		$this->assertEquals('New review.', $data['create'][0]['review']);
388
+		$this->assertEquals($review_2_id, $data['delete'][0]['previous']['id']);
389
+		$this->assertEquals($review_3_id, $data['delete'][1]['previous']['id']);
390 390
 
391
-		$request = new \WP_REST_Request( 'GET', '/wc/v4/products/reviews' );
392
-		$request->set_param( 'product', $product->get_id() );
391
+		$request = new \WP_REST_Request('GET', '/wc/v4/products/reviews');
392
+		$request->set_param('product', $product->get_id());
393 393
 
394
-		$response = $this->server->dispatch( $request );
394
+		$response = $this->server->dispatch($request);
395 395
 		$data     = $response->get_data();
396 396
 
397
-		$this->assertEquals( 3, count( $data ) );
397
+		$this->assertEquals(3, count($data));
398 398
 	}
399 399
 }
400 400
 
Please login to merge, or discard this patch.
unit-tests/AbstractReportsTest.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 namespace WooCommerce\RestApi\UnitTests;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 use \WooCommerce\RestApi\UnitTests\Bootstrap;
11 11
 use \WC_REST_Unit_Test_Case;
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param object $factory Factory object.
29 29
 	 */
30
-	public static function wpSetUpBeforeClass( $factory ) {
30
+	public static function wpSetUpBeforeClass($factory) {
31 31
 		self::$user = $factory->user->create(
32 32
 			array(
33 33
 				'role' => 'administrator',
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 	 * Setup test reports categories data.
40 40
 	 */
41 41
 	public function setUp() {
42
-		if ( ! class_exists( '\WC_Admin_Reports_Sync' ) ) {
43
-			$this->markTestSkipped( 'Skipping reports tests - WC_Admin_Reports_Sync class not found.' );
42
+		if ( ! class_exists('\WC_Admin_Reports_Sync')) {
43
+			$this->markTestSkipped('Skipping reports tests - WC_Admin_Reports_Sync class not found.');
44 44
 			return;
45 45
 		}
46 46
 
47 47
 		parent::setUp();
48
-		wp_set_current_user( self::$user );
48
+		wp_set_current_user(self::$user);
49 49
 
50 50
 		global $wpdb;
51
-		$wpdb->query( "DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Orders_Stats_Data_Store::TABLE_NAME ); // @codingStandardsIgnoreLine.
52
-		$wpdb->query( "DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Products_Data_Store::TABLE_NAME ); // @codingStandardsIgnoreLine.
53
-		$wpdb->query( "DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Coupons_Data_Store::TABLE_NAME ); // @codingStandardsIgnoreLine.
54
-		$wpdb->query( "DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Customers_Data_Store::TABLE_NAME ); // @codingStandardsIgnoreLine.
51
+		$wpdb->query("DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Orders_Stats_Data_Store::TABLE_NAME); // @codingStandardsIgnoreLine.
52
+		$wpdb->query("DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Products_Data_Store::TABLE_NAME); // @codingStandardsIgnoreLine.
53
+		$wpdb->query("DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Coupons_Data_Store::TABLE_NAME); // @codingStandardsIgnoreLine.
54
+		$wpdb->query("DELETE FROM $wpdb->prefix" . \WC_Admin_Reports_Customers_Data_Store::TABLE_NAME); // @codingStandardsIgnoreLine.
55 55
 	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
woocommerce-rest-api.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
  * @package WooCommerce/RestApi
13 13
  */
14 14
 
15
-defined( 'ABSPATH' ) || exit;
15
+defined('ABSPATH') || exit;
16 16
 
17
-if ( version_compare( PHP_VERSION, '5.6.0', '<' ) ) {
17
+if (version_compare(PHP_VERSION, '5.6.0', '<')) {
18 18
 	return;
19 19
 }
20 20
 
@@ -27,11 +27,11 @@  discard block
 block discarded – undo
27 27
 /**
28 28
  * This callback registers this version of the API with WooCommerce.
29 29
  */
30
-$register_callback = function() use ( $version, $init_callback ) {
31
-	if ( ! is_callable( array( wc()->api, 'register' ) ) ) {
30
+$register_callback = function() use ($version, $init_callback) {
31
+	if ( ! is_callable(array(wc()->api, 'register'))) {
32 32
 		return;
33 33
 	}
34
-	wc()->api->register( $version, $init_callback );
34
+	wc()->api->register($version, $init_callback);
35 35
 };
36 36
 
37
-add_action( 'woocommerce_loaded', $register_callback );
37
+add_action('woocommerce_loaded', $register_callback);
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-data-currencies-controller.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since   3.5.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * REST API Data Currencies controller class.
@@ -39,36 +39,36 @@  discard block
 block discarded – undo
39 39
 			$this->namespace, '/' . $this->rest_base, array(
40 40
 				array(
41 41
 					'methods'             => WP_REST_Server::READABLE,
42
-					'callback'            => array( $this, 'get_items' ),
43
-					'permission_callback' => array( $this, 'get_items_permissions_check' ),
42
+					'callback'            => array($this, 'get_items'),
43
+					'permission_callback' => array($this, 'get_items_permissions_check'),
44 44
 				),
45
-				'schema' => array( $this, 'get_public_item_schema' ),
45
+				'schema' => array($this, 'get_public_item_schema'),
46 46
 			)
47 47
 		);
48 48
 		register_rest_route(
49 49
 			$this->namespace, '/' . $this->rest_base . '/current', array(
50 50
 				array(
51 51
 					'methods'             => WP_REST_Server::READABLE,
52
-					'callback'            => array( $this, 'get_current_item' ),
53
-					'permission_callback' => array( $this, 'get_item_permissions_check' ),
52
+					'callback'            => array($this, 'get_current_item'),
53
+					'permission_callback' => array($this, 'get_item_permissions_check'),
54 54
 				),
55
-				'schema' => array( $this, 'get_public_item_schema' ),
55
+				'schema' => array($this, 'get_public_item_schema'),
56 56
 			)
57 57
 		);
58 58
 		register_rest_route(
59 59
 			$this->namespace, '/' . $this->rest_base . '/(?P<currency>[\w-]{3})', array(
60 60
 				array(
61 61
 					'methods'             => WP_REST_Server::READABLE,
62
-					'callback'            => array( $this, 'get_item' ),
63
-					'permission_callback' => array( $this, 'get_item_permissions_check' ),
62
+					'callback'            => array($this, 'get_item'),
63
+					'permission_callback' => array($this, 'get_item_permissions_check'),
64 64
 					'args'                => array(
65 65
 						'location' => array(
66
-							'description' => __( 'ISO4217 currency code.', 'woocommerce' ),
66
+							'description' => __('ISO4217 currency code.', 'woocommerce'),
67 67
 							'type'        => 'string',
68 68
 						),
69 69
 					),
70 70
 				),
71
-				'schema' => array( $this, 'get_public_item_schema' ),
71
+				'schema' => array($this, 'get_public_item_schema'),
72 72
 			)
73 73
 		);
74 74
 	}
@@ -80,18 +80,18 @@  discard block
 block discarded – undo
80 80
 	 * @param  WP_REST_Request $request Request data.
81 81
 	 * @return array|mixed Response data, ready for insertion into collection data.
82 82
 	 */
83
-	public function get_currency( $code = false, $request ) {
83
+	public function get_currency($code = false, $request) {
84 84
 		$currencies = get_woocommerce_currencies();
85 85
 		$data       = array();
86 86
 
87
-		if ( ! array_key_exists( $code, $currencies ) ) {
87
+		if ( ! array_key_exists($code, $currencies)) {
88 88
 			return false;
89 89
 		}
90 90
 
91 91
 		$currency = array(
92 92
 			'code'   => $code,
93
-			'name'   => $currencies[ $code ],
94
-			'symbol' => get_woocommerce_currency_symbol( $code ),
93
+			'name'   => $currencies[$code],
94
+			'symbol' => get_woocommerce_currency_symbol($code),
95 95
 		);
96 96
 
97 97
 		return $currency;
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 * @param  WP_REST_Request $request Request data.
104 104
 	 * @return WP_Error|WP_REST_Response
105 105
 	 */
106
-	public function get_items( $request ) {
106
+	public function get_items($request) {
107 107
 		$currencies = get_woocommerce_currencies();
108
-		foreach ( array_keys( $currencies ) as $code ) {
109
-			$currency = $this->get_currency( $code, $request );
110
-			$response = $this->prepare_item_for_response( $currency, $request );
111
-			$data[]   = $this->prepare_response_for_collection( $response );
108
+		foreach (array_keys($currencies) as $code) {
109
+			$currency = $this->get_currency($code, $request);
110
+			$response = $this->prepare_item_for_response($currency, $request);
111
+			$data[]   = $this->prepare_response_for_collection($response);
112 112
 		}
113 113
 
114
-		return rest_ensure_response( $data );
114
+		return rest_ensure_response($data);
115 115
 	}
116 116
 
117 117
 	/**
@@ -120,12 +120,12 @@  discard block
 block discarded – undo
120 120
 	 * @param  WP_REST_Request $request Request data.
121 121
 	 * @return WP_Error|WP_REST_Response
122 122
 	 */
123
-	public function get_item( $request ) {
124
-		$data = $this->get_currency( strtoupper( $request['currency'] ), $request );
125
-		if ( empty( $data ) ) {
126
-			return new WP_Error( 'woocommerce_rest_data_invalid_currency', __( 'There are no currencies matching these parameters.', 'woocommerce' ), array( 'status' => 404 ) );
123
+	public function get_item($request) {
124
+		$data = $this->get_currency(strtoupper($request['currency']), $request);
125
+		if (empty($data)) {
126
+			return new WP_Error('woocommerce_rest_data_invalid_currency', __('There are no currencies matching these parameters.', 'woocommerce'), array('status' => 404));
127 127
 		}
128
-		return $this->prepare_item_for_response( $data, $request );
128
+		return $this->prepare_item_for_response($data, $request);
129 129
 	}
130 130
 
131 131
 	/**
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 * @param  WP_REST_Request $request Request data.
135 135
 	 * @return WP_Error|WP_REST_Response
136 136
 	 */
137
-	public function get_current_item( $request ) {
138
-		$currency = get_option( 'woocommerce_currency' );
139
-		return $this->prepare_item_for_response( $this->get_currency( $currency, $request ), $request );
137
+	public function get_current_item($request) {
138
+		$currency = get_option('woocommerce_currency');
139
+		return $this->prepare_item_for_response($this->get_currency($currency, $request), $request);
140 140
 	}
141 141
 
142 142
 	/**
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 	 * @param WP_REST_Request $request Request object.
147 147
 	 * @return WP_REST_Response $response Response data.
148 148
 	 */
149
-	public function prepare_item_for_response( $item, $request ) {
150
-		$data     = $this->add_additional_fields_to_object( $item, $request );
151
-		$data     = $this->filter_response_by_context( $data, 'view' );
152
-		$response = rest_ensure_response( $data );
149
+	public function prepare_item_for_response($item, $request) {
150
+		$data     = $this->add_additional_fields_to_object($item, $request);
151
+		$data     = $this->filter_response_by_context($data, 'view');
152
+		$response = rest_ensure_response($data);
153 153
 
154
-		$response->add_links( $this->prepare_links( $item ) );
154
+		$response->add_links($this->prepare_links($item));
155 155
 
156 156
 		/**
157 157
 		 * Filter currency returned from the API.
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		 * @param array            $item     Currency data.
161 161
 		 * @param WP_REST_Request  $request  Request used to generate the response.
162 162
 		 */
163
-		return apply_filters( 'woocommerce_rest_prepare_data_currency', $response, $item, $request );
163
+		return apply_filters('woocommerce_rest_prepare_data_currency', $response, $item, $request);
164 164
 	}
165 165
 
166 166
 	/**
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 * @param object $item Data object.
170 170
 	 * @return array Links for the given currency.
171 171
 	 */
172
-	protected function prepare_links( $item ) {
173
-		$code  = strtoupper( $item['code'] );
172
+	protected function prepare_links($item) {
173
+		$code  = strtoupper($item['code']);
174 174
 		$links = array(
175 175
 			'self'       => array(
176
-				'href' => rest_url( sprintf( '/%s/%s/%s', $this->namespace, $this->rest_base, $code ) ),
176
+				'href' => rest_url(sprintf('/%s/%s/%s', $this->namespace, $this->rest_base, $code)),
177 177
 			),
178 178
 			'collection' => array(
179
-				'href' => rest_url( sprintf( '/%s/%s', $this->namespace, $this->rest_base ) ),
179
+				'href' => rest_url(sprintf('/%s/%s', $this->namespace, $this->rest_base)),
180 180
 			),
181 181
 		);
182 182
 
@@ -197,25 +197,25 @@  discard block
 block discarded – undo
197 197
 			'properties' => array(
198 198
 				'code'   => array(
199 199
 					'type'        => 'string',
200
-					'description' => __( 'ISO4217 currency code.', 'woocommerce' ),
201
-					'context'     => array( 'view' ),
200
+					'description' => __('ISO4217 currency code.', 'woocommerce'),
201
+					'context'     => array('view'),
202 202
 					'readonly'    => true,
203 203
 				),
204 204
 				'name'   => array(
205 205
 					'type'        => 'string',
206
-					'description' => __( 'Full name of currency.', 'woocommerce' ),
207
-					'context'     => array( 'view' ),
206
+					'description' => __('Full name of currency.', 'woocommerce'),
207
+					'context'     => array('view'),
208 208
 					'readonly'    => true,
209 209
 				),
210 210
 				'symbol' => array(
211 211
 					'type'        => 'string',
212
-					'description' => __( 'Currency symbol.', 'woocommerce' ),
213
-					'context'     => array( 'view' ),
212
+					'description' => __('Currency symbol.', 'woocommerce'),
213
+					'context'     => array('view'),
214 214
 					'readonly'    => true,
215 215
 				),
216 216
 			),
217 217
 		);
218 218
 
219
-		return $this->add_additional_fields_schema( $schema );
219
+		return $this->add_additional_fields_schema($schema);
220 220
 	}
221 221
 }
Please login to merge, or discard this patch.
src/RestApi/Version3/class-wc-rest-system-status-tools-controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
  * @since   3.0.0
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 /**
14 14
  * System status tools controller.
Please login to merge, or discard this patch.