Add transients to post tests

This commit is contained in:
Mike Jolley 2019-03-07 11:21:42 +00:00
parent 598ac86e95
commit bb7aa99d4b
2 changed files with 74 additions and 66 deletions

94
composer.lock generated
View File

@ -1,7 +1,7 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "e7a81f490b054c067759791d696be7bd", "content-hash": "e7a81f490b054c067759791d696be7bd",
@ -247,7 +247,7 @@
"homepage": "https://github.com/kukulich" "homepage": "https://github.com/kukulich"
}, },
{ {
"name": "Tomáš Votruba", "name": "Tomas Votruba",
"email": "tomas.vot@gmail.com" "email": "tomas.vot@gmail.com"
}, },
{ {
@ -1275,23 +1275,23 @@
}, },
{ {
"name": "nette/di", "name": "nette/di",
"version": "v2.4.14", "version": "v2.4.15",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/di.git", "url": "https://github.com/nette/di.git",
"reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a" "reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/di/zipball/923da3e2c0aa53162ef455472c0ac7787b096c5a", "url": "https://api.github.com/repos/nette/di/zipball/d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"reference": "923da3e2c0aa53162ef455472c0ac7787b096c5a", "reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-tokenizer": "*", "ext-tokenizer": "*",
"nette/neon": "^2.3.3 || ~3.0.0", "nette/neon": "^2.3.3 || ~3.0.0",
"nette/php-generator": "^2.6.1 || ~3.0.0", "nette/php-generator": "^2.6.1 || ^3.0.0",
"nette/utils": "^2.4.3 || ~3.0.0", "nette/utils": "^2.5.0 || ~3.0.0",
"php": ">=5.6.0" "php": ">=5.6.0"
}, },
"conflict": { "conflict": {
@ -1340,37 +1340,37 @@
"nette", "nette",
"static" "static"
], ],
"time": "2018-09-17T15:47:40+00:00" "time": "2019-01-30T13:26:05+00:00"
}, },
{ {
"name": "nette/finder", "name": "nette/finder",
"version": "v2.4.2", "version": "v2.5.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/finder.git", "url": "https://github.com/nette/finder.git",
"reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2",
"reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"nette/utils": "~2.4", "nette/utils": "^2.4 || ~3.0.0",
"php": ">=5.6.0" "php": ">=7.1"
}, },
"conflict": { "conflict": {
"nette/nette": "<2.2" "nette/nette": "<2.2"
}, },
"require-dev": { "require-dev": {
"nette/tester": "~2.0", "nette/tester": "^2.0",
"tracy/tracy": "^2.3" "tracy/tracy": "^2.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.4-dev" "dev-master": "2.5-dev"
} }
}, },
"autoload": { "autoload": {
@ -1402,7 +1402,7 @@
"iterator", "iterator",
"nette" "nette"
], ],
"time": "2018-06-28T11:49:23+00:00" "time": "2019-02-28T18:13:25+00:00"
}, },
{ {
"name": "nette/http", "name": "nette/http",
@ -1607,21 +1607,21 @@
}, },
{ {
"name": "nette/php-generator", "name": "nette/php-generator",
"version": "v3.0.5", "version": "v3.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/php-generator.git", "url": "https://github.com/nette/php-generator.git",
"reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" "reference": "9de4e093a130f7a1bd175198799ebc0efbac6924"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", "url": "https://api.github.com/repos/nette/php-generator/zipball/9de4e093a130f7a1bd175198799ebc0efbac6924",
"reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", "reference": "9de4e093a130f7a1bd175198799ebc0efbac6924",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"nette/utils": "^2.4.2 || ~3.0.0", "nette/utils": "^2.4.2 || ~3.0.0",
"php": ">=7.0" "php": ">=7.1"
}, },
"conflict": { "conflict": {
"nette/nette": "<2.2" "nette/nette": "<2.2"
@ -1633,7 +1633,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "3.0-dev" "dev-master": "3.2-dev"
} }
}, },
"autoload": { "autoload": {
@ -1657,7 +1657,7 @@
"homepage": "https://nette.org/contributors" "homepage": "https://nette.org/contributors"
} }
], ],
"description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.",
"homepage": "https://nette.org", "homepage": "https://nette.org",
"keywords": [ "keywords": [
"code", "code",
@ -1665,7 +1665,7 @@
"php", "php",
"scaffolding" "scaffolding"
], ],
"time": "2018-08-09T14:32:27+00:00" "time": "2018-11-27T19:00:14+00:00"
}, },
{ {
"name": "nette/reflection", "name": "nette/reflection",
@ -1799,32 +1799,29 @@
}, },
{ {
"name": "nette/safe-stream", "name": "nette/safe-stream",
"version": "v2.3.3", "version": "v2.4.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/safe-stream.git", "url": "https://github.com/nette/safe-stream.git",
"reference": "0fcd45ae82be5817f4b3ad25bc8955968f355412" "reference": "5e46d5fe397956d697501785d50b16fecea8e935"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/safe-stream/zipball/0fcd45ae82be5817f4b3ad25bc8955968f355412", "url": "https://api.github.com/repos/nette/safe-stream/zipball/5e46d5fe397956d697501785d50b16fecea8e935",
"reference": "0fcd45ae82be5817f4b3ad25bc8955968f355412", "reference": "5e46d5fe397956d697501785d50b16fecea8e935",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=5.3.1" "php": ">=7.1"
},
"conflict": {
"nette/nette": "<2.2"
}, },
"require-dev": { "require-dev": {
"nette/tester": "~1.7", "nette/tester": "^2.0",
"tracy/tracy": "^2.3" "tracy/tracy": "^2.3"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.3-dev" "dev-master": "2.4-dev"
} }
}, },
"autoload": { "autoload": {
@ -1856,7 +1853,7 @@
"nette", "nette",
"safe" "safe"
], ],
"time": "2017-07-13T18:20:37+00:00" "time": "2019-02-06T00:22:25+00:00"
}, },
{ {
"name": "nette/utils", "name": "nette/utils",
@ -3896,27 +3893,28 @@
}, },
{ {
"name": "tracy/tracy", "name": "tracy/tracy",
"version": "v2.5.5", "version": "v2.6.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nette/tracy.git", "url": "https://github.com/nette/tracy.git",
"reference": "35fa649b483b28e16f61de07110ea0585fc8d6ea" "reference": "e179856e5dcc3ced99df1596cd299246fb1c3ac2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nette/tracy/zipball/35fa649b483b28e16f61de07110ea0585fc8d6ea", "url": "https://api.github.com/repos/nette/tracy/zipball/e179856e5dcc3ced99df1596cd299246fb1c3ac2",
"reference": "35fa649b483b28e16f61de07110ea0585fc8d6ea", "reference": "e179856e5dcc3ced99df1596cd299246fb1c3ac2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"ext-json": "*", "ext-json": "*",
"ext-session": "*", "ext-session": "*",
"php": ">=5.4.4" "php": ">=7.1"
}, },
"require-dev": { "require-dev": {
"nette/di": "~2.3", "nette/di": "^2.4 || ~3.0.0",
"nette/tester": "~1.7", "nette/tester": "^2.1",
"nette/utils": "~2.3" "nette/utils": "^2.4 || ^3.0",
"psr/log": "^1.0"
}, },
"suggest": { "suggest": {
"https://nette.org/donate": "Please support Tracy via a donation" "https://nette.org/donate": "Please support Tracy via a donation"
@ -3924,7 +3922,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.5-dev" "dev-master": "2.6-dev"
} }
}, },
"autoload": { "autoload": {
@ -3932,7 +3930,7 @@
"src" "src"
], ],
"files": [ "files": [
"src/shortcuts.php" "src/Tracy/shortcuts.php"
] ]
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
@ -3958,7 +3956,7 @@
"nette", "nette",
"profiler" "profiler"
], ],
"time": "2018-11-05T15:10:59+00:00" "time": "2019-03-01T02:12:13+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",

View File

@ -603,27 +603,37 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
} }
// Test POST requests. // Test POST requests.
$post_response = wp_safe_remote_post( $post_success = get_transient( 'woocommerce_remote_post_test_success' );
'https://www.paypal.com/cgi-bin/webscr',
array( if ( false === $post_success ) {
'timeout' => 10, $post_response = wp_safe_remote_post(
'user-agent' => 'WooCommerce/' . WC()->version, 'https://www.paypal.com/cgi-bin/webscr',
'httpversion' => '1.1', array(
'body' => array( 'timeout' => 10,
'cmd' => '_notify-validate', 'user-agent' => 'WooCommerce/' . WC()->version,
), 'httpversion' => '1.1',
) 'body' => array(
); 'cmd' => '_notify-validate',
$post_response_successful = false; ),
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { )
$post_response_successful = true; );
$post_response_successful = false;
if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) {
$post_response_successful = true;
}
set_transient( 'woocommerce_remote_post_test_success', $post_response_successful, HOUR_IN_SECONDS );
} }
// Test GET requests. // Test GET requests.
$get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) ); $get_success = get_transient( 'woocommerce_remote_get_test_success' );
$get_response_successful = false;
if ( ! is_wp_error( $get_response ) && $get_response['response']['code'] >= 200 && $get_response['response']['code'] < 300 ) { if ( false === $get_success ) {
$get_response_successful = true; $get_response = wp_safe_remote_get( 'https://woocommerce.com/wc-api/product-key-api?request=ping&network=' . ( is_multisite() ? '1' : '0' ) );
$get_response_successful = false;
if ( ! is_wp_error( $get_response ) && $get_response['response']['code'] >= 200 && $get_response['response']['code'] < 300 ) {
$get_response_successful = true;
}
set_transient( 'woocommerce_remote_get_test_success', $get_response_successful, HOUR_IN_SECONDS );
} }
$database_version = wc_get_server_database_version(); $database_version = wc_get_server_database_version();