Skip to content

Commit

Permalink
Merge pull request woocommerce#1570 from woocommerce/phpcs/tests
Browse files Browse the repository at this point in the history
Phpcs sniff fixes for unit tests
  • Loading branch information
rrennick authored Feb 15, 2019
2 parents f9a69ec + ebbf5c6 commit 35d31cc
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 150 deletions.
2 changes: 1 addition & 1 deletion tests/api/admin-notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function test_get_notes() {
public function test_get_warning_notes() {
wp_set_current_user( $this->user );

$request = new WP_REST_Request( 'GET', $this->endpoint );
$request = new WP_REST_Request( 'GET', $this->endpoint );
$request->set_query_params( array( 'type' => 'warning' ) );
$response = $this->server->dispatch( $request );
$notes = $response->get_data();
Expand Down
4 changes: 2 additions & 2 deletions tests/api/product-reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WC_Tests_API_Product_Reviews extends WC_REST_Unit_Test_Case {
public function setUp() {
parent::setUp();

$this->user = $this->factory->user->create(
$this->user = $this->factory->user->create(
array(
'role' => 'administrator',
)
Expand All @@ -35,7 +35,7 @@ public function setUp() {
*/
public function test_product_review_embed() {
wp_set_current_user( $this->user );
$product = WC_Helper_Product::create_simple_product();
$product = WC_Helper_Product::create_simple_product();
WC_Helper_Product::create_product_review( $product->get_id() );

$request = new WP_REST_Request( 'GET', '/wc/v4/products/reviews' );
Expand Down
4 changes: 2 additions & 2 deletions tests/api/products.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class WC_Tests_API_Products extends WC_REST_Unit_Test_Case {
public function setUp() {
parent::setUp();

$this->user = $this->factory->user->create(
$this->user = $this->factory->user->create(
array(
'role' => 'administrator',
)
Expand Down Expand Up @@ -52,7 +52,7 @@ public function test_product_schema() {
);

foreach ( $properties as $property_key => $property ) {
if ( in_array( $property_key, $properties_to_embed ) ) {
if ( in_array( $property_key, $properties_to_embed, true ) ) {
$this->assertEquals( array( 'view', 'edit', 'embed' ), $property['context'] );
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/api/reports-customers-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function setUp() {
*
* @since 3.5.0
*/
public function _test_register_routes() {
public function test_register_routes() {
$routes = $this->server->get_routes();

$this->assertArrayHasKey( $this->endpoint, $routes );
Expand Down Expand Up @@ -156,8 +156,8 @@ public function test_get_reports() {
// Test name and last_order parameters.
$request->set_query_params(
array(
'search' => 'Jeff',
'last_order_after' => date( 'Y-m-d' ) . 'T00:00:00Z',
'search' => 'Jeff',
'last_order_after' => date( 'Y-m-d' ) . 'T00:00:00Z',
)
);
$response = $this->server->dispatch( $request );
Expand Down
6 changes: 3 additions & 3 deletions tests/api/reports-customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function test_get_reports() {

WC_Helper_Queue::run_all_pending();

$request = new WP_REST_Request( 'GET', $this->endpoint );
$request = new WP_REST_Request( 'GET', $this->endpoint );
$request->set_query_params(
array(
'per_page' => 5,
Expand Down Expand Up @@ -175,8 +175,8 @@ public function test_get_reports() {
// Test name and last_order parameters.
$request->set_query_params(
array(
'search' => 'Justin',
'last_order_after' => date( 'Y-m-d' ) . 'T00:00:00Z',
'search' => 'Justin',
'last_order_after' => date( 'Y-m-d' ) . 'T00:00:00Z',
)
);
$response = $this->server->dispatch( $request );
Expand Down
2 changes: 1 addition & 1 deletion tests/api/reports-downloads-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function test_get_report() {
$object->set_user_ip_address( '1.2.3.4' );
$id = $object->save();

$time = time();
$time = time();
$request = new WP_REST_Request( 'GET', $this->endpoint );
$request->set_query_params(
array(
Expand Down
4 changes: 2 additions & 2 deletions tests/api/reports-interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,9 @@ public function test_normalize_between_date_params() {
$params = array( 'a', 'b', 'c', 'd' );
$result = WC_Admin_Reports_Interval::normalize_between_params( $request, $params, true );
$expected = array(
'b_after' => 1,
'b_after' => 1,
'b_before' => 5,
'c_after' => 2,
'c_after' => 2,
'c_before' => 4,
);

Expand Down
3 changes: 2 additions & 1 deletion tests/api/reports-orders-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function test_get_reports() {

$this->assertEquals( 200, $response->get_status() );
$this->assertEquals( 2, count( $reports ) ); // totals and intervals.
// $this->assertEquals( array(), $reports ); // @todo Update results after implement report interface.
// @todo Update results after implement report interface.
// $this->assertEquals( array(), $reports ); // @codingStandardsIgnoreLine.
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/api/reports-performance-indicators.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ public function test_get_indicators() {

WC_Helper_Queue::run_all_pending();

$time = time();
$time = time();
$request = new WP_REST_Request( 'GET', $this->endpoint );
$request->set_query_params(
array(
'before' => date( 'Y-m-d 23:59:59', $time ),
'after' => date( 'Y-m-d H:00:00', $time - ( 7 * DAY_IN_SECONDS ) ),
'stats' => 'orders/orders_count,downloads/download_count,test/bogus_stat',
'before' => date( 'Y-m-d 23:59:59', $time ),
'after' => date( 'Y-m-d H:00:00', $time - ( 7 * DAY_IN_SECONDS ) ),
'stats' => 'orders/orders_count,downloads/download_count,test/bogus_stat',
)
);
$response = $this->server->dispatch( $request );
Expand Down Expand Up @@ -126,8 +126,8 @@ public function test_get_indicators_empty_request() {
$request = new WP_REST_Request( 'GET', $this->endpoint );
$request->set_query_params(
array(
'before' => date( 'Y-m-d 23:59:59', $time ),
'after' => date( 'Y-m-d H:00:00', $time - ( 7 * DAY_IN_SECONDS ) ),
'before' => date( 'Y-m-d 23:59:59', $time ),
'after' => date( 'Y-m-d H:00:00', $time - ( 7 * DAY_IN_SECONDS ) ),
)
);
$response = $this->server->dispatch( $request );
Expand Down
4 changes: 2 additions & 2 deletions tests/api/reports-stock-stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function test_get_reports() {
$in_stock->save();
}

$request = new WP_REST_Request( 'GET', $this->endpoint );
$request = new WP_REST_Request( 'GET', $this->endpoint );
$response = $this->server->dispatch( $request );
$reports = $response->get_data();

Expand All @@ -94,7 +94,7 @@ public function test_get_reports() {
$backorder_stock->set_stock_status( 'onbackorder' );
$backorder_stock->save();

$request = new WP_REST_Request( 'GET', $this->endpoint );
$request = new WP_REST_Request( 'GET', $this->endpoint );
$response = $this->server->dispatch( $request );
$reports = $response->get_data();

Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function _manually_load_plugin() {
* This matches how we mock the flags in jest.
*/
function wc_admin_get_feature_config() {
$config = json_decode( file_get_contents( dirname( dirname( __FILE__ ) ) . '/config/development.json' ) );
$config = json_decode( file_get_contents( dirname( dirname( __FILE__ ) ) . '/config/development.json' ) ); // @codingStandardsIgnoreLine.
$flags = array();
foreach ( $config->features as $feature => $bool ) {
$flags[ $feature ] = $bool;
Expand Down
Loading

0 comments on commit 35d31cc

Please sign in to comment.