Completed
Push — master ( adb8dc...103e24 )
by Mike
04:42 queued 01:51
created
unit-tests/Bootstrap.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	 * Init unit testing library.
31 31
 	 */
32 32
 	public function init() {
33
-		$this->wc_tests_dir = dirname( dirname( dirname( __FILE__ ) ) ) . '/woocommerce/tests';
34
-		$this->wp_tests_dir = getenv( 'WP_TESTS_DIR' );
33
+		$this->wc_tests_dir = dirname(dirname(dirname(__FILE__))) . '/woocommerce/tests';
34
+		$this->wp_tests_dir = getenv('WP_TESTS_DIR');
35 35
 
36
-		if ( ! $this->wp_tests_dir ) {
37
-			$this->wp_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
36
+		if ( ! $this->wp_tests_dir) {
37
+			$this->wp_tests_dir = rtrim(sys_get_temp_dir(), '/\\') . '/wordpress-tests-lib';
38 38
 		}
39 39
 
40 40
 		$this->setup_hooks();
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return boolean
57 57
 	 */
58 58
 	protected function wc_admin_exists() {
59
-		return file_exists( dirname( dirname( __DIR__ ) ) . '/woocommerce-admin/woocommerce-admin.php' );
59
+		return file_exists(dirname(dirname(__DIR__)) . '/woocommerce-admin/woocommerce-admin.php');
60 60
 	}
61 61
 
62 62
 	/**
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
 		// Give access to tests_add_filter() function.
67 67
 		require_once $this->wp_tests_dir . '/includes/functions.php';
68 68
 
69
-		\tests_add_filter( 'muplugins_loaded', function() {
70
-			require_once dirname( dirname( __DIR__ ) ) . '/woocommerce/woocommerce.php';
71
-			require_once dirname( __DIR__ ) . '/woocommerce-rest-api.php';
69
+		\tests_add_filter('muplugins_loaded', function() {
70
+			require_once dirname(dirname(__DIR__)) . '/woocommerce/woocommerce.php';
71
+			require_once dirname(__DIR__) . '/woocommerce-rest-api.php';
72 72
 
73
-			if ( $this->wc_admin_exists() ) {
74
-				require_once dirname( dirname( __DIR__ ) ) . '/woocommerce-admin/woocommerce-admin.php';
73
+			if ($this->wc_admin_exists()) {
74
+				require_once dirname(dirname(__DIR__)) . '/woocommerce-admin/woocommerce-admin.php';
75 75
 			}
76 76
 		} );
77 77
 
78
-		\tests_add_filter( 'setup_theme', function() {
79
-			echo \esc_html( 'Installing WooCommerce...' . PHP_EOL );
78
+		\tests_add_filter('setup_theme', function() {
79
+			echo \esc_html('Installing WooCommerce...' . PHP_EOL);
80 80
 
81
-			define( 'WP_UNINSTALL_PLUGIN', true );
82
-			define( 'WC_REMOVE_ALL_DATA', true );
83
-			include dirname( dirname( __DIR__ ) ) . '/woocommerce/uninstall.php';
81
+			define('WP_UNINSTALL_PLUGIN', true);
82
+			define('WC_REMOVE_ALL_DATA', true);
83
+			include dirname(dirname(__DIR__)) . '/woocommerce/uninstall.php';
84 84
 
85 85
 			\WC_Install::install();
86 86
 
87
-			if ( $this->wc_admin_exists() ) {
88
-				echo esc_html( 'Installing WooCommerce Admin...' . PHP_EOL );
89
-				require_once dirname( dirname( __DIR__ ) ) . '/woocommerce-admin/includes/class-wc-admin-install.php';
87
+			if ($this->wc_admin_exists()) {
88
+				echo esc_html('Installing WooCommerce Admin...' . PHP_EOL);
89
+				require_once dirname(dirname(__DIR__)) . '/woocommerce-admin/includes/class-wc-admin-install.php';
90 90
 				\WC_Admin_Install::create_tables();
91 91
 				\WC_Admin_Install::create_events();
92 92
 			}
Please login to merge, or discard this patch.
unit-tests/Helpers/AdminNotesHelper.php 1 patch
Spacing   +28 added lines, -28 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\Helpers;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 use \WC_Data_Store;
13 13
 use \WC_Admin_Note;
@@ -24,24 +24,24 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	public static function reset_notes_dbs() {
26 26
 		global $wpdb;
27
-		$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wc_admin_notes" ); // @codingStandardsIgnoreLine.
28
-		$wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}wc_admin_note_actions" ); // @codingStandardsIgnoreLine.
27
+		$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}wc_admin_notes"); // @codingStandardsIgnoreLine.
28
+		$wpdb->query("TRUNCATE TABLE {$wpdb->prefix}wc_admin_note_actions"); // @codingStandardsIgnoreLine.
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * Create two notes that we can use for notes REST API tests
33 33
 	 */
34 34
 	public static function add_notes_for_tests() {
35
-		$data_store = WC_Data_Store::load( 'admin-note' );
35
+		$data_store = WC_Data_Store::load('admin-note');
36 36
 
37 37
 		$note_1 = new WC_Admin_Note();
38
-		$note_1->set_title( 'PHPUNIT_TEST_NOTE_1_TITLE' );
39
-		$note_1->set_content( 'PHPUNIT_TEST_NOTE_1_CONTENT' );
40
-		$note_1->set_content_data( (object) array( 'amount' => 1.23 ) );
41
-		$note_1->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
42
-		$note_1->set_icon( 'info' );
43
-		$note_1->set_name( 'PHPUNIT_TEST_NOTE_NAME' );
44
-		$note_1->set_source( 'PHPUNIT_TEST' );
38
+		$note_1->set_title('PHPUNIT_TEST_NOTE_1_TITLE');
39
+		$note_1->set_content('PHPUNIT_TEST_NOTE_1_CONTENT');
40
+		$note_1->set_content_data((object) array('amount' => 1.23));
41
+		$note_1->set_type(WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL);
42
+		$note_1->set_icon('info');
43
+		$note_1->set_name('PHPUNIT_TEST_NOTE_NAME');
44
+		$note_1->set_source('PHPUNIT_TEST');
45 45
 		$note_1->add_action(
46 46
 			'PHPUNIT_TEST_NOTE_1_ACTION_1_SLUG',
47 47
 			'PHPUNIT_TEST_NOTE_1_ACTION_1_LABEL',
@@ -55,27 +55,27 @@  discard block
 block discarded – undo
55 55
 		$note_1->save();
56 56
 
57 57
 		$note_2 = new WC_Admin_Note();
58
-		$note_2->set_title( 'PHPUNIT_TEST_NOTE_2_TITLE' );
59
-		$note_2->set_content( 'PHPUNIT_TEST_NOTE_2_CONTENT' );
60
-		$note_2->set_content_data( (object) array( 'amount' => 4.56 ) );
61
-		$note_2->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_WARNING );
62
-		$note_2->set_icon( 'info' );
63
-		$note_2->set_name( 'PHPUNIT_TEST_NOTE_NAME' );
64
-		$note_2->set_source( 'PHPUNIT_TEST' );
65
-		$note_2->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED );
58
+		$note_2->set_title('PHPUNIT_TEST_NOTE_2_TITLE');
59
+		$note_2->set_content('PHPUNIT_TEST_NOTE_2_CONTENT');
60
+		$note_2->set_content_data((object) array('amount' => 4.56));
61
+		$note_2->set_type(WC_Admin_Note::E_WC_ADMIN_NOTE_WARNING);
62
+		$note_2->set_icon('info');
63
+		$note_2->set_name('PHPUNIT_TEST_NOTE_NAME');
64
+		$note_2->set_source('PHPUNIT_TEST');
65
+		$note_2->set_status(WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED);
66 66
 		// This note has no actions.
67 67
 		$note_2->save();
68 68
 
69 69
 		$note_3 = new WC_Admin_Note();
70
-		$note_3->set_title( 'PHPUNIT_TEST_NOTE_3_TITLE' );
71
-		$note_3->set_content( 'PHPUNIT_TEST_NOTE_3_CONTENT' );
72
-		$note_3->set_content_data( (object) array( 'amount' => 7.89 ) );
73
-		$note_3->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
74
-		$note_3->set_icon( 'info' );
75
-		$note_3->set_name( 'PHPUNIT_TEST_NOTE_NAME' );
76
-		$note_3->set_source( 'PHPUNIT_TEST' );
77
-		$note_3->set_status( WC_Admin_Note::E_WC_ADMIN_NOTE_SNOOZED );
78
-		$note_3->set_date_reminder( time() - HOUR_IN_SECONDS );
70
+		$note_3->set_title('PHPUNIT_TEST_NOTE_3_TITLE');
71
+		$note_3->set_content('PHPUNIT_TEST_NOTE_3_CONTENT');
72
+		$note_3->set_content_data((object) array('amount' => 7.89));
73
+		$note_3->set_type(WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL);
74
+		$note_3->set_icon('info');
75
+		$note_3->set_name('PHPUNIT_TEST_NOTE_NAME');
76
+		$note_3->set_source('PHPUNIT_TEST');
77
+		$note_3->set_status(WC_Admin_Note::E_WC_ADMIN_NOTE_SNOOZED);
78
+		$note_3->set_date_reminder(time() - HOUR_IN_SECONDS);
79 79
 		// This note has no actions.
80 80
 		$note_3->save();
81 81
 
Please login to merge, or discard this patch.
unit-tests/Helpers/ProductHelper.php 1 patch
Spacing   +48 added lines, -48 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\Helpers;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 use \WC_Product_Simple;
11 11
 use \WC_Product_External;
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param int $product_id ID to delete.
29 29
 	 */
30
-	public static function delete_product( $product_id ) {
31
-		$product = \wc_get_product( $product_id );
32
-		if ( $product ) {
33
-			$product->delete( true );
30
+	public static function delete_product($product_id) {
31
+		$product = \wc_get_product($product_id);
32
+		if ($product) {
33
+			$product->delete(true);
34 34
 		}
35 35
 	}
36 36
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @param bool $save Save or return object.
42 42
 	 * @return WC_Product_Simple
43 43
 	 */
44
-	public static function create_simple_product( $save = true ) {
44
+	public static function create_simple_product($save = true) {
45 45
 		$product = new WC_Product_Simple();
46 46
 		$product->set_props(
47 47
 			array(
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 			)
59 59
 		);
60 60
 
61
-		if ( $save ) {
61
+		if ($save) {
62 62
 			$product->save();
63
-			return \wc_get_product( $product->get_id() );
63
+			return \wc_get_product($product->get_id());
64 64
 		} else {
65 65
 			return $product;
66 66
 		}
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 		);
86 86
 		$product->save();
87 87
 
88
-		return \wc_get_product( $product->get_id() );
88
+		return \wc_get_product($product->get_id());
89 89
 	}
90 90
 
91 91
 	/**
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 				'sku'  => 'DUMMY GROUPED SKU',
105 105
 			)
106 106
 		);
107
-		$product->set_children( array( $simple_product_1->get_id(), $simple_product_2->get_id() ) );
107
+		$product->set_children(array($simple_product_1->get_id(), $simple_product_2->get_id()));
108 108
 		$product->save();
109 109
 
110
-		return \wc_get_product( $product->get_id() );
110
+		return \wc_get_product($product->get_id());
111 111
 	}
112 112
 
113 113
 	/**
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 			)
127 127
 		);
128 128
 
129
-		$attribute_data = self::create_attribute( 'size', array( 'small', 'large' ) ); // Create all attribute related things.
129
+		$attribute_data = self::create_attribute('size', array('small', 'large')); // Create all attribute related things.
130 130
 		$attributes     = array();
131 131
 		$attribute      = new WC_Product_Attribute();
132
-		$attribute->set_id( $attribute_data['attribute_id'] );
133
-		$attribute->set_name( $attribute_data['attribute_taxonomy'] );
134
-		$attribute->set_options( $attribute_data['term_ids'] );
135
-		$attribute->set_position( 1 );
136
-		$attribute->set_visible( true );
137
-		$attribute->set_variation( true );
132
+		$attribute->set_id($attribute_data['attribute_id']);
133
+		$attribute->set_name($attribute_data['attribute_taxonomy']);
134
+		$attribute->set_options($attribute_data['term_ids']);
135
+		$attribute->set_position(1);
136
+		$attribute->set_visible(true);
137
+		$attribute->set_variation(true);
138 138
 		$attributes[] = $attribute;
139 139
 
140
-		$product->set_attributes( $attributes );
140
+		$product->set_attributes($attributes);
141 141
 		$product->save();
142 142
 
143 143
 		$variation_1 = new WC_Product_Variation();
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 				'regular_price' => 10,
149 149
 			)
150 150
 		);
151
-		$variation_1->set_attributes( array( 'pa_size' => 'small' ) );
151
+		$variation_1->set_attributes(array('pa_size' => 'small'));
152 152
 		$variation_1->save();
153 153
 
154 154
 		$variation_2 = new WC_Product_Variation();
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 				'regular_price' => 15,
160 160
 			)
161 161
 		);
162
-		$variation_2->set_attributes( array( 'pa_size' => 'large' ) );
162
+		$variation_2->set_attributes(array('pa_size' => 'large'));
163 163
 		$variation_2->save();
164 164
 
165
-		return \wc_get_product( $product->get_id() );
165
+		return \wc_get_product($product->get_id());
166 166
 	}
167 167
 
168 168
 	/**
@@ -174,28 +174,28 @@  discard block
 block discarded – undo
174 174
 	 * @param array(string) $terms          Terms to create for the attribute.
175 175
 	 * @return array
176 176
 	 */
177
-	public static function create_attribute( $raw_name = 'size', $terms = array( 'small' ) ) {
177
+	public static function create_attribute($raw_name = 'size', $terms = array('small')) {
178 178
 		global $wpdb, $wc_product_attributes;
179 179
 
180 180
 		// Make sure caches are clean.
181
-		\delete_transient( 'wc_attribute_taxonomies' );
182
-		WC_Cache_Helper::incr_cache_prefix( 'woocommerce-attributes' );
181
+		\delete_transient('wc_attribute_taxonomies');
182
+		WC_Cache_Helper::incr_cache_prefix('woocommerce-attributes');
183 183
 
184 184
 		// These are exported as labels, so convert the label to a name if possible first.
185
-		$attribute_labels = \wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name' );
186
-		$attribute_name   = \array_search( $raw_name, $attribute_labels, true );
185
+		$attribute_labels = \wp_list_pluck(wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name');
186
+		$attribute_name   = \array_search($raw_name, $attribute_labels, true);
187 187
 
188
-		if ( ! $attribute_name ) {
189
-			$attribute_name = \wc_sanitize_taxonomy_name( $raw_name );
188
+		if ( ! $attribute_name) {
189
+			$attribute_name = \wc_sanitize_taxonomy_name($raw_name);
190 190
 		}
191 191
 
192
-		$attribute_id = \wc_attribute_taxonomy_id_by_name( $attribute_name );
192
+		$attribute_id = \wc_attribute_taxonomy_id_by_name($attribute_name);
193 193
 
194
-		if ( ! $attribute_id ) {
195
-			$taxonomy_name = \wc_attribute_taxonomy_name( $attribute_name );
194
+		if ( ! $attribute_id) {
195
+			$taxonomy_name = \wc_attribute_taxonomy_name($attribute_name);
196 196
 
197 197
 			// Degister taxonomy which other tests may have created...
198
-			\unregister_taxonomy( $taxonomy_name );
198
+			\unregister_taxonomy($taxonomy_name);
199 199
 
200 200
 			$attribute_id = \wc_create_attribute(
201 201
 				array(
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			// Register as taxonomy.
211 211
 			\register_taxonomy(
212 212
 				$taxonomy_name,
213
-				apply_filters( 'woocommerce_taxonomy_objects_' . $taxonomy_name, array( 'product' ) ),
213
+				apply_filters('woocommerce_taxonomy_objects_' . $taxonomy_name, array('product')),
214 214
 				apply_filters(
215 215
 					'woocommerce_taxonomy_args_' . $taxonomy_name,
216 216
 					array(
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
 			// Set product attributes global.
229 229
 			$wc_product_attributes = array();
230 230
 
231
-			foreach ( \wc_get_attribute_taxonomies() as $taxonomy ) {
232
-				$wc_product_attributes[ \wc_attribute_taxonomy_name( $taxonomy->attribute_name ) ] = $taxonomy;
231
+			foreach (\wc_get_attribute_taxonomies() as $taxonomy) {
232
+				$wc_product_attributes[\wc_attribute_taxonomy_name($taxonomy->attribute_name)] = $taxonomy;
233 233
 			}
234 234
 		}
235 235
 
236
-		$attribute = \wc_get_attribute( $attribute_id );
236
+		$attribute = \wc_get_attribute($attribute_id);
237 237
 		$return    = array(
238 238
 			'attribute_name'     => $attribute->name,
239 239
 			'attribute_taxonomy' => $attribute->slug,
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 			'term_ids'           => array(),
242 242
 		);
243 243
 
244
-		foreach ( $terms as $term ) {
245
-			$result = \term_exists( $term, $attribute->slug );
244
+		foreach ($terms as $term) {
245
+			$result = \term_exists($term, $attribute->slug);
246 246
 
247
-			if ( ! $result ) {
248
-				$result               = wp_insert_term( $term, $attribute->slug );
247
+			if ( ! $result) {
248
+				$result               = wp_insert_term($term, $attribute->slug);
249 249
 				$return['term_ids'][] = $result['term_id'];
250 250
 			} else {
251 251
 				$return['term_ids'][] = $result['term_id'];
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 	 *
263 263
 	 * @since 2.3
264 264
 	 */
265
-	public static function delete_attribute( $attribute_id ) {
265
+	public static function delete_attribute($attribute_id) {
266 266
 		global $wpdb;
267 267
 
268
-		$attribute_id = \absint( $attribute_id );
268
+		$attribute_id = \absint($attribute_id);
269 269
 
270 270
 		$wpdb->query(
271
-			$wpdb->prepare( "DELETE FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = %d", $attribute_id )
271
+			$wpdb->prepare("DELETE FROM {$wpdb->prefix}woocommerce_attribute_taxonomies WHERE attribute_id = %d", $attribute_id)
272 272
 		);
273 273
 	}
274 274
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @param string $review_content string Content to use for the product review.
281 281
 	 * @return integer Product Review ID.
282 282
 	 */
283
-	public static function create_product_review( $product_id, $review_content = 'Review content here' ) {
283
+	public static function create_product_review($product_id, $review_content = 'Review content here') {
284 284
 		$data = array(
285 285
 			'comment_post_ID'      => $product_id,
286 286
 			'comment_author'       => 'admin',
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 			'comment_approved'     => 1,
292 292
 			'comment_type'         => 'review',
293 293
 		);
294
-		return \wp_insert_comment( $data );
294
+		return \wp_insert_comment($data);
295 295
 	}
296 296
 
297 297
 	/**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 *
301 301
 	 * @param int $id ID to update.
302 302
 	 */
303
-	public static function save_post_test_update_meta_data_direct( $id ) {
304
-		\update_post_meta( $id, '_test2', 'world' );
303
+	public static function save_post_test_update_meta_data_direct($id) {
304
+		\update_post_meta($id, '_test2', 'world');
305 305
 	}
306 306
 }
Please login to merge, or discard this patch.
unit-tests/Helpers/OrderHelper.php 1 patch
Spacing   +36 added lines, -36 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\Helpers;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 use \WC_Tax;
11 11
 use \WC_Shipping_Rate;
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param int $order_id ID of the order to delete.
26 26
 	 */
27
-	public static function delete_order( $order_id ) {
27
+	public static function delete_order($order_id) {
28 28
 
29
-		$order = wc_get_order( $order_id );
29
+		$order = wc_get_order($order_id);
30 30
 
31 31
 		// Delete all products in the order.
32
-		foreach ( $order->get_items() as $item ) {
33
-			\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::delete_product( $item['product_id'] );
32
+		foreach ($order->get_items() as $item) {
33
+			\WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::delete_product($item['product_id']);
34 34
 		}
35 35
 
36 36
 		ShippingHelper::delete_simple_flat_rate();
37 37
 
38 38
 		// Delete the order post.
39
-		$order->delete( true );
39
+		$order->delete(true);
40 40
 	}
41 41
 
42 42
 	/**
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return WC_Order
52 52
 	 */
53
-	public static function create_order( $customer_id = 1, $product = null ) {
53
+	public static function create_order($customer_id = 1, $product = null) {
54 54
 
55
-		if ( ! is_a( $product, 'WC_Product' ) ) {
55
+		if ( ! is_a($product, 'WC_Product')) {
56 56
 			$product = \WooCommerce\RestApi\UnitTests\Helpers\ProductHelper::create_simple_product();
57 57
 		}
58 58
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		);
67 67
 
68 68
 		$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // Required, else wc_create_order throws an exception
69
-		$order                  = wc_create_order( $order_data );
69
+		$order                  = wc_create_order($order_data);
70 70
 
71 71
 		// Add order products
72 72
 		$item = new WC_Order_Item_Product();
@@ -74,54 +74,54 @@  discard block
 block discarded – undo
74 74
 			array(
75 75
 				'product'  => $product,
76 76
 				'quantity' => 4,
77
-				'subtotal' => wc_get_price_excluding_tax( $product, array( 'qty' => 4 ) ),
78
-				'total'    => wc_get_price_excluding_tax( $product, array( 'qty' => 4 ) ),
77
+				'subtotal' => wc_get_price_excluding_tax($product, array('qty' => 4)),
78
+				'total'    => wc_get_price_excluding_tax($product, array('qty' => 4)),
79 79
 			)
80 80
 		);
81 81
 		$item->save();
82
-		$order->add_item( $item );
82
+		$order->add_item($item);
83 83
 
84 84
 		// Set billing address
85
-		$order->set_billing_first_name( 'Jeroen' );
86
-		$order->set_billing_last_name( 'Sormani' );
87
-		$order->set_billing_company( 'WooCompany' );
88
-		$order->set_billing_address_1( 'WooAddress' );
89
-		$order->set_billing_address_2( '' );
90
-		$order->set_billing_city( 'WooCity' );
91
-		$order->set_billing_state( 'NY' );
92
-		$order->set_billing_postcode( '123456' );
93
-		$order->set_billing_country( 'US' );
94
-		$order->set_billing_email( '[email protected]' );
95
-		$order->set_billing_phone( '555-32123' );
85
+		$order->set_billing_first_name('Jeroen');
86
+		$order->set_billing_last_name('Sormani');
87
+		$order->set_billing_company('WooCompany');
88
+		$order->set_billing_address_1('WooAddress');
89
+		$order->set_billing_address_2('');
90
+		$order->set_billing_city('WooCity');
91
+		$order->set_billing_state('NY');
92
+		$order->set_billing_postcode('123456');
93
+		$order->set_billing_country('US');
94
+		$order->set_billing_email('[email protected]');
95
+		$order->set_billing_phone('555-32123');
96 96
 
97 97
 		// Add shipping costs
98
-		$shipping_taxes = WC_Tax::calc_shipping_tax( '10', WC_Tax::get_shipping_tax_rates() );
99
-		$rate           = new WC_Shipping_Rate( 'flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate' );
98
+		$shipping_taxes = WC_Tax::calc_shipping_tax('10', WC_Tax::get_shipping_tax_rates());
99
+		$rate           = new WC_Shipping_Rate('flat_rate_shipping', 'Flat rate shipping', '10', $shipping_taxes, 'flat_rate');
100 100
 		$item           = new WC_Order_Item_Shipping();
101 101
 		$item->set_props(
102 102
 			array(
103 103
 				'method_title' => $rate->label,
104 104
 				'method_id'    => $rate->id,
105
-				'total'        => wc_format_decimal( $rate->cost ),
105
+				'total'        => wc_format_decimal($rate->cost),
106 106
 				'taxes'        => $rate->taxes,
107 107
 			)
108 108
 		);
109
-		foreach ( $rate->get_meta_data() as $key => $value ) {
110
-			$item->add_meta_data( $key, $value, true );
109
+		foreach ($rate->get_meta_data() as $key => $value) {
110
+			$item->add_meta_data($key, $value, true);
111 111
 		}
112
-		$order->add_item( $item );
112
+		$order->add_item($item);
113 113
 
114 114
 		// Set payment gateway
115 115
 		$payment_gateways = WC()->payment_gateways->payment_gateways();
116
-		$order->set_payment_method( $payment_gateways['bacs'] );
116
+		$order->set_payment_method($payment_gateways['bacs']);
117 117
 
118 118
 		// Set totals
119
-		$order->set_shipping_total( 10 );
120
-		$order->set_discount_total( 0 );
121
-		$order->set_discount_tax( 0 );
122
-		$order->set_cart_tax( 0 );
123
-		$order->set_shipping_tax( 0 );
124
-		$order->set_total( 50 ); // 4 x $10 simple helper product
119
+		$order->set_shipping_total(10);
120
+		$order->set_discount_total(0);
121
+		$order->set_discount_tax(0);
122
+		$order->set_cart_tax(0);
123
+		$order->set_shipping_tax(0);
124
+		$order->set_total(50); // 4 x $10 simple helper product
125 125
 		$order->save();
126 126
 
127 127
 		return $order;
Please login to merge, or discard this patch.
unit-tests/Helpers/CustomerHelper.php 1 patch
Spacing   +30 added lines, -30 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\Helpers;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 use \WC_Customer;
11 11
 
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 			'calculated_shipping' => false,
42 42
 		);
43 43
 
44
-		self::set_customer_details( $customer_data );
44
+		self::set_customer_details($customer_data);
45 45
 
46
-		$customer = new WC_Customer( 0, true );
46
+		$customer = new WC_Customer(0, true);
47 47
 
48 48
 		return $customer;
49 49
 	}
@@ -51,24 +51,24 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * Creates a customer in the tests DB.
53 53
 	 */
54
-	public static function create_customer( $username = 'testcustomer', $password = 'hunter2', $email = '[email protected]' ) {
54
+	public static function create_customer($username = 'testcustomer', $password = 'hunter2', $email = '[email protected]') {
55 55
 		$customer = new WC_Customer();
56
-		$customer->set_billing_country( 'US' );
57
-		$customer->set_first_name( 'Justin' );
58
-		$customer->set_billing_state( 'PA' );
59
-		$customer->set_billing_postcode( '19123' );
60
-		$customer->set_billing_city( 'Philadelphia' );
61
-		$customer->set_billing_address( '123 South Street' );
62
-		$customer->set_billing_address_2( 'Apt 1' );
63
-		$customer->set_shipping_country( 'US' );
64
-		$customer->set_shipping_state( 'PA' );
65
-		$customer->set_shipping_postcode( '19123' );
66
-		$customer->set_shipping_city( 'Philadelphia' );
67
-		$customer->set_shipping_address( '123 South Street' );
68
-		$customer->set_shipping_address_2( 'Apt 1' );
69
-		$customer->set_username( $username );
70
-		$customer->set_password( $password );
71
-		$customer->set_email( $email );
56
+		$customer->set_billing_country('US');
57
+		$customer->set_first_name('Justin');
58
+		$customer->set_billing_state('PA');
59
+		$customer->set_billing_postcode('19123');
60
+		$customer->set_billing_city('Philadelphia');
61
+		$customer->set_billing_address('123 South Street');
62
+		$customer->set_billing_address_2('Apt 1');
63
+		$customer->set_shipping_country('US');
64
+		$customer->set_shipping_state('PA');
65
+		$customer->set_shipping_postcode('19123');
66
+		$customer->set_shipping_city('Philadelphia');
67
+		$customer->set_shipping_address('123 South Street');
68
+		$customer->set_shipping_address_2('Apt 1');
69
+		$customer->set_username($username);
70
+		$customer->set_password($password);
71
+		$customer->set_email($email);
72 72
 		$customer->save();
73 73
 		return $customer;
74 74
 	}
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @return array
80 80
 	 */
81 81
 	public static function get_expected_store_location() {
82
-		return array( 'GB', '', '', '' );
82
+		return array('GB', '', '', '');
83 83
 	}
84 84
 
85 85
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return array
89 89
 	 */
90 90
 	public static function get_customer_details() {
91
-		return WC()->session->get( 'customer' );
91
+		return WC()->session->get('customer');
92 92
 	}
93 93
 
94 94
 	/**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return array
98 98
 	 */
99 99
 	public static function get_chosen_shipping_methods() {
100
-		return WC()->session->get( 'chosen_shipping_methods' );
100
+		return WC()->session->get('chosen_shipping_methods');
101 101
 	}
102 102
 
103 103
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @return string base or billing
107 107
 	 */
108 108
 	public static function get_tax_based_on() {
109
-		return get_option( 'woocommerce_tax_based_on' );
109
+		return get_option('woocommerce_tax_based_on');
110 110
 	}
111 111
 
112 112
 	/**
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @param string $default_shipping_method Shipping Method slug
116 116
 	 */
117
-	public static function set_customer_details( $customer_details ) {
118
-		WC()->session->set( 'customer', array_map( 'strval', $customer_details ) );
117
+	public static function set_customer_details($customer_details) {
118
+		WC()->session->set('customer', array_map('strval', $customer_details));
119 119
 	}
120 120
 
121 121
 	/**
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param string $chosen_shipping_method Shipping Method slug
125 125
 	 */
126
-	public static function set_chosen_shipping_methods( $chosen_shipping_methods ) {
127
-		WC()->session->set( 'chosen_shipping_methods', $chosen_shipping_methods );
126
+	public static function set_chosen_shipping_methods($chosen_shipping_methods) {
127
+		WC()->session->set('chosen_shipping_methods', $chosen_shipping_methods);
128 128
 	}
129 129
 
130 130
 	/**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param string $default_shipping_method Shipping Method slug
134 134
 	 */
135
-	public static function set_tax_based_on( $default_shipping_method ) {
136
-		update_option( 'woocommerce_tax_based_on', $default_shipping_method );
135
+	public static function set_tax_based_on($default_shipping_method) {
136
+		update_option('woocommerce_tax_based_on', $default_shipping_method);
137 137
 	}
138 138
 }
Please login to merge, or discard this patch.
unit-tests/Helpers/QueueHelper.php 1 patch
Spacing   +4 added lines, -4 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\Helpers;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 /**
13 13
  * Class QueueHelper.
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	public static function run_all_pending() {
42 42
 		$jobs = self::get_all_pending();
43 43
 
44
-		foreach ( $jobs as $job ) {
44
+		foreach ($jobs as $job) {
45 45
 			$job->execute();
46 46
 		}
47 47
 	}
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 		$jobs = self::get_all_pending();
56 56
 
57 57
 		$queue_runner = new \ActionScheduler_QueueRunner();
58
-		foreach ( $jobs as $job_id => $job ) {
59
-			$queue_runner->process_action( $job_id );
58
+		foreach ($jobs as $job_id => $job) {
59
+			$queue_runner->process_action($job_id);
60 60
 		}
61 61
 	}
62 62
 }
Please login to merge, or discard this patch.
unit-tests/Helpers/CouponHelper.php 1 patch
Spacing   +25 added lines, -25 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\Helpers;
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 use \WC_Coupon;
13 13
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return WC_Coupon
28 28
 	 */
29
-	public static function create_coupon( $coupon_code = 'dummycoupon', $meta = array() ) {
29
+	public static function create_coupon($coupon_code = 'dummycoupon', $meta = array()) {
30 30
 		// Insert post
31 31
 		$coupon_id = wp_insert_post(
32 32
 			array(
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
 		);
62 62
 
63 63
 		// Update meta.
64
-		foreach ( $meta as $key => $value ) {
65
-			update_post_meta( $coupon_id, $key, $value );
64
+		foreach ($meta as $key => $value) {
65
+			update_post_meta($coupon_id, $key, $value);
66 66
 		}
67 67
 
68
-		return new WC_Coupon( $coupon_code );
68
+		return new WC_Coupon($coupon_code);
69 69
 	}
70 70
 
71 71
 	/**
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return bool
77 77
 	 */
78
-	public static function delete_coupon( $coupon_id ) {
79
-		wp_delete_post( $coupon_id, true );
78
+	public static function delete_coupon($coupon_id) {
79
+		wp_delete_post($coupon_id, true);
80 80
 
81 81
 		return true;
82 82
 	}
@@ -86,18 +86,18 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param string $coupon_type
88 88
 	 */
89
-	public static function register_custom_type( $coupon_type ) {
89
+	public static function register_custom_type($coupon_type) {
90 90
 		static $filters_added = false;
91
-		if ( isset( self::$custom_types[ $coupon_type ] ) ) {
91
+		if (isset(self::$custom_types[$coupon_type])) {
92 92
 			return;
93 93
 		}
94 94
 
95
-		self::$custom_types[ $coupon_type ] = "Testing custom type {$coupon_type}";
95
+		self::$custom_types[$coupon_type] = "Testing custom type {$coupon_type}";
96 96
 
97
-		if ( ! $filters_added ) {
98
-			add_filter( 'woocommerce_coupon_discount_types', array( __CLASS__, 'filter_discount_types' ) );
99
-			add_filter( 'woocommerce_coupon_get_discount_amount', array( __CLASS__, 'filter_get_discount_amount' ), 10, 5 );
100
-			add_filter( 'woocommerce_coupon_is_valid_for_product', '__return_true' );
97
+		if ( ! $filters_added) {
98
+			add_filter('woocommerce_coupon_discount_types', array(__CLASS__, 'filter_discount_types'));
99
+			add_filter('woocommerce_coupon_get_discount_amount', array(__CLASS__, 'filter_get_discount_amount'), 10, 5);
100
+			add_filter('woocommerce_coupon_is_valid_for_product', '__return_true');
101 101
 			$filters_added = true;
102 102
 		}
103 103
 	}
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @param $coupon_type
109 109
 	 */
110
-	public static function unregister_custom_type( $coupon_type ) {
111
-		unset( self::$custom_types[ $coupon_type ] );
112
-		if ( empty( self::$custom_types ) ) {
113
-			remove_filter( 'woocommerce_coupon_discount_types', array( __CLASS__, 'filter_discount_types' ) );
114
-			remove_filter( 'woocommerce_coupon_get_discount_amount', array( __CLASS__, 'filter_get_discount_amount' ) );
115
-			remove_filter( 'woocommerce_coupon_is_valid_for_product', '__return_true' );
110
+	public static function unregister_custom_type($coupon_type) {
111
+		unset(self::$custom_types[$coupon_type]);
112
+		if (empty(self::$custom_types)) {
113
+			remove_filter('woocommerce_coupon_discount_types', array(__CLASS__, 'filter_discount_types'));
114
+			remove_filter('woocommerce_coupon_get_discount_amount', array(__CLASS__, 'filter_get_discount_amount'));
115
+			remove_filter('woocommerce_coupon_is_valid_for_product', '__return_true');
116 116
 		}
117 117
 	}
118 118
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @param array $discount_types
123 123
 	 * @return array
124 124
 	 */
125
-	public static function filter_discount_types( $discount_types ) {
126
-		return array_merge( $discount_types, self::$custom_types );
125
+	public static function filter_discount_types($discount_types) {
126
+		return array_merge($discount_types, self::$custom_types);
127 127
 	}
128 128
 
129 129
 	/**
@@ -137,11 +137,11 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return float
139 139
 	 */
140
-	public static function filter_get_discount_amount( $discount, $discounting_amount, $item, $single, $coupon ) {
141
-		if ( ! isset( self::$custom_types [ $coupon->get_discount_type() ] ) ) {
140
+	public static function filter_get_discount_amount($discount, $discounting_amount, $item, $single, $coupon) {
141
+		if ( ! isset(self::$custom_types [$coupon->get_discount_type()])) {
142 142
 			return $discount;
143 143
 		}
144 144
 
145
-		return (float) $coupon->get_amount() * ( $discounting_amount / 100 );
145
+		return (float) $coupon->get_amount() * ($discounting_amount / 100);
146 146
 	}
147 147
 }
Please login to merge, or discard this patch.
unit-tests/Helpers/ShippingHelper.php 1 patch
Spacing   +7 added lines, -7 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\Helpers;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 use \WC_Cache_Helper;
11 11
 use \WC;
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 			'cost'         => '10',
31 31
 		);
32 32
 
33
-		update_option( 'woocommerce_flat_rate_settings', $flat_rate_settings );
34
-		update_option( 'woocommerce_flat_rate', array() );
35
-		WC_Cache_Helper::get_transient_version( 'shipping', true );
33
+		update_option('woocommerce_flat_rate_settings', $flat_rate_settings);
34
+		update_option('woocommerce_flat_rate', array());
35
+		WC_Cache_Helper::get_transient_version('shipping', true);
36 36
 		WC()->shipping()->load_shipping_methods();
37 37
 	}
38 38
 
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
 	 * @since 2.3
43 43
 	 */
44 44
 	public static function delete_simple_flat_rate() {
45
-		delete_option( 'woocommerce_flat_rate_settings' );
46
-		delete_option( 'woocommerce_flat_rate' );
47
-		WC_Cache_Helper::get_transient_version( 'shipping', true );
45
+		delete_option('woocommerce_flat_rate_settings');
46
+		delete_option('woocommerce_flat_rate');
47
+		WC_Cache_Helper::get_transient_version('shipping', true);
48 48
 		WC()->shipping()->unregister_shipping_methods();
49 49
 	}
50 50
 }
Please login to merge, or discard this patch.
unit-tests/Helpers/SettingsHelper.php 1 patch
Spacing   +5 added lines, -5 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\Helpers;
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Class SettingsHelper.
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 	 * @since 3.0.0
19 19
 	 */
20 20
 	public static function register() {
21
-		\add_filter( 'woocommerce_settings_groups', array( __CLASS__, 'register_groups' ) );
22
-		\add_filter( 'woocommerce_settings-test', array( __CLASS__, 'register_test_settings' ) );
21
+		\add_filter('woocommerce_settings_groups', array(__CLASS__, 'register_groups'));
22
+		\add_filter('woocommerce_settings-test', array(__CLASS__, 'register_test_settings'));
23 23
 	}
24 24
 
25 25
 	/**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param  array $groups
30 30
 	 * @return array
31 31
 	 */
32
-	public static function register_groups( $groups ) {
32
+	public static function register_groups($groups) {
33 33
 		$groups[] = array(
34 34
 			'id'          => 'test',
35 35
 			'bad'         => 'value',
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param  array $settings
64 64
 	 * @return array
65 65
 	 */
66
-	public static function register_test_settings( $settings ) {
66
+	public static function register_test_settings($settings) {
67 67
 		$settings[] = array(
68 68
 			'id'          => 'woocommerce_shop_page_display',
69 69
 			'label'       => 'Shop page display',
Please login to merge, or discard this patch.