Skip to content

Commit 885736b

Browse files
committed
Minor bugs in tests resolved.
1 parent 0773277 commit 885736b

File tree

10 files changed

+63
-28
lines changed

10 files changed

+63
-28
lines changed

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"wp-coding-standards/wpcs": "^2.3"
3232
},
3333
"config": {
34-
"optimize-autoloader": true
34+
"optimize-autoloader": true,
35+
"process-timeout": 0
3536
},
3637
"autoload": {
3738
"files": [
@@ -53,17 +54,17 @@
5354
"scripts": {
5455
"install-test-env": "bash bin/install-test-env.sh",
5556
"docker-build": "bash bin/run-docker.sh build",
56-
"docker-run": [
57-
"@docker-build",
58-
"bash bin/run-docker.sh run"
59-
],
57+
"docker-run": "bash bin/run-docker.sh run",
6058
"docker-destroy": "docker-compose down",
61-
"local-app": "@docker-run -a",
62-
"local-test": "@docker-run -t",
63-
"test": [
64-
"composer install --no-dev",
65-
"@local-test"
59+
"build-and-run": [
60+
"Composer\\Config::disableProcessTimeout",
61+
"@docker-build",
62+
"@docker-run"
6663
],
64+
"build-local-app": "@docker-build -a",
65+
"build-local-test": "@docker-build -t",
66+
"run-local-app": "@docker-run -a",
67+
"run-local-test": "@docker-run -t",
6768
"lint": "vendor/bin/phpcs"
6869
},
6970
"support" : {

docker/testing.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ RUN curl -sS https://getcomposer.org/installer | php -- \
5151
# Add composer global binaries to PATH
5252
ENV PATH "$PATH:~/.composer/vendor/bin"
5353

54+
# Install parallel installation composer plugin by Hiraku NAKANO https://github.com/hirak/prestissimo
55+
RUN composer global require hirak/prestissimo
56+
5457
# Configure php
5558
RUN echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini
5659

tests/_support/Helper/crud-helpers/order.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,18 @@ public function print_downloadables( $id ) {
468468

469469
return $nodes;
470470
}
471+
472+
public function delete_order( $order ) {
473+
474+
// Delete all products in the order.
475+
foreach ( $order->get_items() as $item ) {
476+
$product = wc_get_product( $item['product_id'] );
477+
if ( $product ) {
478+
$product->delete( true );
479+
}
480+
}
481+
482+
// Delete the order post.
483+
$order->delete( true );
484+
}
471485
}

tests/wpunit/ConnectionPaginationTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@ function( $key_a, $key_b ) {
224224
}
225225

226226
public function testOrdersPagination() {
227+
wp_set_current_user( $this->shop_manager );
228+
229+
$query = new \WC_Order_Query();
230+
$old_orders = $query->get_orders();
231+
foreach ( $old_orders as $order ) {
232+
$this->orders->delete_order( $order );
233+
}
234+
unset( $old_orders );
235+
unset( $query );
236+
227237
$orders = array(
228238
$this->orders->create(),
229239
$this->orders->create(),
@@ -255,8 +265,6 @@ function( $key_a, $key_b ) {
255265
}
256266
';
257267

258-
wp_set_current_user( $this->shop_manager );
259-
260268
/**
261269
* Assertion One
262270
*

tests/wpunit/IntrospectionQueryTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

3-
class IntrospectionQueryTest extends \Codeception\TestCase\WPTestCase
4-
{
3+
class IntrospectionQueryTest extends \Codeception\TestCase\WPTestCase {
54

65
public function setUp() {
76
// before
87
parent::setUp();
98

109
$settings = get_option( 'graphql_general_settings' );
10+
if ( ! $settings ) {
11+
$settings = array();
12+
}
1113
$settings['public_introspection_enabled'] = 'on';
1214
update_option( 'graphql_general_settings', $settings );
1315
WPGraphQL::clear_schema();

tests/wpunit/OrderQueriesTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,17 @@ public function testOrderQueryAndIds() {
235235
}
236236

237237
public function testOrdersQueryAndWhereArgs() {
238+
$query = new \WC_Order_Query();
239+
$old_orders = $query->get_orders();
240+
foreach ( $old_orders as $order ) {
241+
$this->order_helper->delete_order( $order );
242+
}
243+
unset( $old_orders );
244+
unset( $query );
245+
238246
$customer = $this->customer_helper->create();
239247
$product = $this->product_helper->create_simple();
240248
$orders = array(
241-
$this->order,
242249
$this->order_helper->create(
243250
array(),
244251
array(

tests/wpunit/ProductQueriesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public function testProductsQueryAndWhereArgs() {
651651
$product_b = new \WC_Product( $id_b );
652652

653653
if ( floatval( $product_a->get_price() ) === floatval( $product_b->get_price() ) ) {
654-
return 0;
654+
return $id_a > $id_b ? -1 : 1;
655655
}
656656
return floatval( $product_a->get_price() ) > floatval( $product_b->get_price() ) ? -1 : 1;
657657
},

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInita19c98089e83bf1ea084032a65b4d4fa::getLoader();
7+
return ComposerAutoloaderInit2fa8cc4089933233a2ec1576fa073991::getLoader();

vendor/composer/autoload_real.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInita19c98089e83bf1ea084032a65b4d4fa
5+
class ComposerAutoloaderInit2fa8cc4089933233a2ec1576fa073991
66
{
77
private static $loader;
88

@@ -22,15 +22,15 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInita19c98089e83bf1ea084032a65b4d4fa', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInit2fa8cc4089933233a2ec1576fa073991', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
27-
spl_autoload_unregister(array('ComposerAutoloaderInita19c98089e83bf1ea084032a65b4d4fa', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInit2fa8cc4089933233a2ec1576fa073991', 'loadClassLoader'));
2828

2929
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
3030
if ($useStaticLoader) {
3131
require_once __DIR__ . '/autoload_static.php';
3232

33-
call_user_func(\Composer\Autoload\ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa::getInitializer($loader));
33+
call_user_func(\Composer\Autoload\ComposerStaticInit2fa8cc4089933233a2ec1576fa073991::getInitializer($loader));
3434
} else {
3535
$map = require __DIR__ . '/autoload_namespaces.php';
3636
foreach ($map as $namespace => $path) {
@@ -51,19 +51,19 @@ public static function getLoader()
5151
$loader->register(true);
5252

5353
if ($useStaticLoader) {
54-
$includeFiles = Composer\Autoload\ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa::$files;
54+
$includeFiles = Composer\Autoload\ComposerStaticInit2fa8cc4089933233a2ec1576fa073991::$files;
5555
} else {
5656
$includeFiles = require __DIR__ . '/autoload_files.php';
5757
}
5858
foreach ($includeFiles as $fileIdentifier => $file) {
59-
composerRequirea19c98089e83bf1ea084032a65b4d4fa($fileIdentifier, $file);
59+
composerRequire2fa8cc4089933233a2ec1576fa073991($fileIdentifier, $file);
6060
}
6161

6262
return $loader;
6363
}
6464
}
6565

66-
function composerRequirea19c98089e83bf1ea084032a65b4d4fa($fileIdentifier, $file)
66+
function composerRequire2fa8cc4089933233a2ec1576fa073991($fileIdentifier, $file)
6767
{
6868
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
6969
require $file;

vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa
7+
class ComposerStaticInit2fa8cc4089933233a2ec1576fa073991
88
{
99
public static $files = array (
1010
'944484f100dc1864a5320474d49ebd5a' => __DIR__ . '/../..' . '/includes/connection/wc-cpt-connection-args.php',
@@ -176,9 +176,9 @@ class ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa
176176
public static function getInitializer(ClassLoader $loader)
177177
{
178178
return \Closure::bind(function () use ($loader) {
179-
$loader->prefixLengthsPsr4 = ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa::$prefixLengthsPsr4;
180-
$loader->prefixDirsPsr4 = ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa::$prefixDirsPsr4;
181-
$loader->classMap = ComposerStaticInita19c98089e83bf1ea084032a65b4d4fa::$classMap;
179+
$loader->prefixLengthsPsr4 = ComposerStaticInit2fa8cc4089933233a2ec1576fa073991::$prefixLengthsPsr4;
180+
$loader->prefixDirsPsr4 = ComposerStaticInit2fa8cc4089933233a2ec1576fa073991::$prefixDirsPsr4;
181+
$loader->classMap = ComposerStaticInit2fa8cc4089933233a2ec1576fa073991::$classMap;
182182

183183
}, null, ClassLoader::class);
184184
}

0 commit comments

Comments
 (0)