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

View File

@ -603,27 +603,37 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
}
// Test POST requests.
$post_response = wp_safe_remote_post(
'https://www.paypal.com/cgi-bin/webscr',
array(
'timeout' => 10,
'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_success = get_transient( 'woocommerce_remote_post_test_success' );
if ( false === $post_success ) {
$post_response = wp_safe_remote_post(
'https://www.paypal.com/cgi-bin/webscr',
array(
'timeout' => 10,
'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;
}
set_transient( 'woocommerce_remote_post_test_success', $post_response_successful, HOUR_IN_SECONDS );
}
// 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_response_successful = false;
if ( ! is_wp_error( $get_response ) && $get_response['response']['code'] >= 200 && $get_response['response']['code'] < 300 ) {
$get_response_successful = true;
$get_success = get_transient( 'woocommerce_remote_get_test_success' );
if ( false === $get_success ) {
$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();