Updated PHPUnit to 7.5.14

This commit is contained in:
Claudio Sanches 2019-07-18 22:02:58 -03:00
parent d034131781
commit 67212d1303
6 changed files with 136 additions and 502 deletions

View File

@ -8,19 +8,19 @@
"minimum-stability": "dev",
"require": {
"automattic/jetpack-autoloader": "1.2.0",
"php": "^5.6|^7.0",
"php": ">=5.6|>=7.0",
"composer/installers": "1.6.0",
"woocommerce/woocommerce-blocks": "2.3.0-beta",
"woocommerce/woocommerce-rest-api": "1.0.3"
},
"require-dev": {
"myclabs/deep-copy": "1.7.0",
"phpunit/phpunit": "6.5.14",
"phpunit/phpunit": "7.5.14",
"woocommerce/woocommerce-sniffs": "0.0.6"
},
"config": {
"platform": {
"php": "7.0"
"php": "7.1"
},
"preferred-install": {
"woocommerce/woocommerce-rest-api": "dist",

304
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "2ae85d17d88de2a1ff50e32bbd85b1db",
"content-hash": "8b2833a3907261e9b1fb056fe56c9dfb",
"packages": [
{
"name": "automattic/jetpack-autoloader",
@ -319,32 +319,34 @@
},
{
"name": "doctrine/instantiator",
"version": "1.0.5",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
"reference": "a2c590166b2133a4633738648b6b064edae0814a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
"php": "^7.1"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"doctrine/coding-standard": "^6.0",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
"phpbench/phpbench": "^0.13",
"phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.2.x-dev"
}
},
"autoload": {
@ -364,12 +366,12 @@
}
],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"constructor",
"instantiate"
],
"time": "2015-06-14T21:17:01+00:00"
"time": "2019-03-17T17:37:11+00:00"
},
{
"name": "myclabs/deep-copy",
@ -418,22 +420,22 @@
},
{
"name": "phar-io/manifest",
"version": "1.0.1",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/phar-io/manifest.git",
"reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0"
"reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0",
"reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0",
"url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
"reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-phar": "*",
"phar-io/version": "^1.0.1",
"phar-io/version": "^2.0",
"php": "^5.6 || ^7.0"
},
"type": "library",
@ -469,20 +471,20 @@
}
],
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
"time": "2017-03-05T18:14:27+00:00"
"time": "2018-07-08T19:23:20+00:00"
},
{
"name": "phar-io/version",
"version": "1.0.1",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "a70c0ced4be299a63d32fa96d9281d03e94041df"
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df",
"reference": "a70c0ced4be299a63d32fa96d9281d03e94041df",
"url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6",
"reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6",
"shasum": ""
},
"require": {
@ -516,7 +518,7 @@
}
],
"description": "Library for handling version information and constraints",
"time": "2017-03-05T17:38:23+00:00"
"time": "2018-07-08T19:19:57+00:00"
},
{
"name": "phpcompatibility/php-compatibility",
@ -893,40 +895,40 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "5.3.2",
"version": "6.1.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "c89677919c5dd6d3b3852f230a663118762218ac"
"reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c89677919c5dd6d3b3852f230a663118762218ac",
"reference": "c89677919c5dd6d3b3852f230a663118762218ac",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
"reference": "807e6013b00af69b6c5d9ceb4282d0393dbb9d8d",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-xmlwriter": "*",
"php": "^7.0",
"phpunit/php-file-iterator": "^1.4.2",
"php": "^7.1",
"phpunit/php-file-iterator": "^2.0",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^2.0.1",
"phpunit/php-token-stream": "^3.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.0",
"sebastian/environment": "^3.1 || ^4.0",
"sebastian/version": "^2.0.1",
"theseer/tokenizer": "^1.1"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^7.0"
},
"suggest": {
"ext-xdebug": "^2.5.5"
"ext-xdebug": "^2.6.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.3.x-dev"
"dev-master": "6.1-dev"
}
},
"autoload": {
@ -952,29 +954,32 @@
"testing",
"xunit"
],
"time": "2018-04-06T15:36:58+00:00"
"time": "2018-10-31T16:06:48+00:00"
},
{
"name": "phpunit/php-file-iterator",
"version": "1.4.5",
"version": "2.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
"reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4"
"reference": "050bedf145a257b1ff02746c31894800e5122946"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4",
"reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4",
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946",
"reference": "050bedf145a257b1ff02746c31894800e5122946",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "2.0.x-dev"
}
},
"autoload": {
@ -989,7 +994,7 @@
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
@ -999,7 +1004,7 @@
"filesystem",
"iterator"
],
"time": "2017-11-27T13:52:08+00:00"
"time": "2018-09-13T20:33:42+00:00"
},
{
"name": "phpunit/php-text-template",
@ -1044,28 +1049,28 @@
},
{
"name": "phpunit/php-timer",
"version": "1.0.9",
"version": "2.1.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f"
"reference": "1038454804406b0b5f5f520358e78c1c2f71501e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e",
"reference": "1038454804406b0b5f5f520358e78c1c2f71501e",
"shasum": ""
},
"require": {
"php": "^5.3.3 || ^7.0"
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0"
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "2.1-dev"
}
},
"autoload": {
@ -1080,7 +1085,7 @@
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sb@sebastian-bergmann.de",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
@ -1089,33 +1094,33 @@
"keywords": [
"timer"
],
"time": "2017-02-26T11:10:40+00:00"
"time": "2019-06-07T04:22:29+00:00"
},
{
"name": "phpunit/php-token-stream",
"version": "2.0.2",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "791198a2c6254db10131eecfe8c06670700904db"
"reference": "c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/791198a2c6254db10131eecfe8c06670700904db",
"reference": "791198a2c6254db10131eecfe8c06670700904db",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c",
"reference": "c4a66b97f040e3e20b3aa2a243230a1c3a9f7c8c",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": "^7.0"
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^6.2.4"
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -1138,57 +1143,57 @@
"keywords": [
"tokenizer"
],
"time": "2017-11-27T05:48:46+00:00"
"time": "2019-07-08T05:24:54+00:00"
},
{
"name": "phpunit/phpunit",
"version": "6.5.14",
"version": "7.5.14",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7"
"reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/bac23fe7ff13dbdb461481f706f0e9fe746334b7",
"reference": "bac23fe7ff13dbdb461481f706f0e9fe746334b7",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2834789aeb9ac182ad69bfdf9ae91856a59945ff",
"reference": "2834789aeb9ac182ad69bfdf9ae91856a59945ff",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.1",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"myclabs/deep-copy": "^1.6.1",
"phar-io/manifest": "^1.0.1",
"phar-io/version": "^1.0",
"php": "^7.0",
"myclabs/deep-copy": "^1.7",
"phar-io/manifest": "^1.0.2",
"phar-io/version": "^2.0",
"php": "^7.1",
"phpspec/prophecy": "^1.7",
"phpunit/php-code-coverage": "^5.3",
"phpunit/php-file-iterator": "^1.4.3",
"phpunit/php-code-coverage": "^6.0.7",
"phpunit/php-file-iterator": "^2.0.1",
"phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^1.0.9",
"phpunit/phpunit-mock-objects": "^5.0.9",
"sebastian/comparator": "^2.1",
"sebastian/diff": "^2.0",
"sebastian/environment": "^3.1",
"phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0",
"sebastian/environment": "^4.0",
"sebastian/exporter": "^3.1",
"sebastian/global-state": "^2.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/resource-operations": "^1.0",
"sebastian/resource-operations": "^2.0",
"sebastian/version": "^2.0.1"
},
"conflict": {
"phpdocumentor/reflection-docblock": "3.0.2",
"phpunit/dbunit": "<3.0"
"phpunit/phpunit-mock-objects": "*"
},
"require-dev": {
"ext-pdo": "*"
},
"suggest": {
"ext-soap": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "^1.1"
"phpunit/php-invoker": "^2.0"
},
"bin": [
"phpunit"
@ -1196,7 +1201,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.5.x-dev"
"dev-master": "7.5-dev"
}
},
"autoload": {
@ -1222,67 +1227,7 @@
"testing",
"xunit"
],
"time": "2019-02-01T05:22:47+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "5.0.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f",
"reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.5",
"php": "^7.0",
"phpunit/php-text-template": "^1.2.1",
"sebastian/exporter": "^3.1"
},
"conflict": {
"phpunit/phpunit": "<6.0"
},
"require-dev": {
"phpunit/phpunit": "^6.5.11"
},
"suggest": {
"ext-soap": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0.x-dev"
}
},
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de",
"role": "lead"
}
],
"description": "Mock Object library for PHPUnit",
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
"keywords": [
"mock",
"xunit"
],
"abandoned": true,
"time": "2018-08-09T05:50:03+00:00"
"time": "2019-07-15T06:24:08+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -1331,30 +1276,30 @@
},
{
"name": "sebastian/comparator",
"version": "2.1.3",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "34369daee48eafb2651bea869b4b15d75ccc35f9"
"reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9",
"reference": "34369daee48eafb2651bea869b4b15d75ccc35f9",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
"reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da",
"shasum": ""
},
"require": {
"php": "^7.0",
"sebastian/diff": "^2.0 || ^3.0",
"php": "^7.1",
"sebastian/diff": "^3.0",
"sebastian/exporter": "^3.1"
},
"require-dev": {
"phpunit/phpunit": "^6.4"
"phpunit/phpunit": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -1391,32 +1336,33 @@
"compare",
"equality"
],
"time": "2018-02-01T13:46:46+00:00"
"time": "2018-07-12T15:12:46+00:00"
},
{
"name": "sebastian/diff",
"version": "2.0.1",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd"
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/347c1d8b49c5c3ee30c7040ea6fc446790e6bddd",
"reference": "347c1d8b49c5c3ee30c7040ea6fc446790e6bddd",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"shasum": ""
},
"require": {
"php": "^7.0"
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^6.2"
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -1441,34 +1387,40 @@
"description": "Diff implementation",
"homepage": "https://github.com/sebastianbergmann/diff",
"keywords": [
"diff"
"diff",
"udiff",
"unidiff",
"unified diff"
],
"time": "2017-08-03T08:09:46+00:00"
"time": "2019-02-04T06:01:07+00:00"
},
{
"name": "sebastian/environment",
"version": "3.1.0",
"version": "4.2.2",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5"
"reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5",
"reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
"reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
"shasum": ""
},
"require": {
"php": "^7.0"
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "^6.1"
"phpunit/phpunit": "^7.5"
},
"suggest": {
"ext-posix": "*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
"dev-master": "4.2-dev"
}
},
"autoload": {
@ -1493,7 +1445,7 @@
"environment",
"hhvm"
],
"time": "2017-07-01T08:51:00+00:00"
"time": "2019-05-05T09:05:15+00:00"
},
{
"name": "sebastian/exporter",
@ -1760,25 +1712,25 @@
},
{
"name": "sebastian/resource-operations",
"version": "1.0.0",
"version": "2.0.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/resource-operations.git",
"reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52"
"reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
"reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52",
"url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
"reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9",
"shasum": ""
},
"require": {
"php": ">=5.6.0"
"php": "^7.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "2.0-dev"
}
},
"autoload": {
@ -1798,7 +1750,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2015-07-28T20:34:47+00:00"
"time": "2018-10-04T04:07:39+00:00"
},
{
"name": "sebastian/version",
@ -2133,10 +2085,10 @@
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^5.6|^7.0"
"php": ">=5.6|>=7.0"
},
"platform-dev": [],
"platform-overrides": {
"php": "7.0"
"php": "7.1"
}
}

View File

@ -7,7 +7,6 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
verbose="true"
syntaxCheck="true"
>
<testsuites>
<testsuite name="WooCommerce Test Suite">
@ -44,6 +43,6 @@
</whitelist>
</filter>
<listeners>
<listener class="SpeedTrapListener" file="tests/includes/speed-trap-listener.php" />
<listener class="WC_SpeedTrapListener" file="tests/includes/speed-trap-listener.php" />
</listeners>
</phpunit>

View File

@ -53,6 +53,9 @@ class WC_Unit_Tests_Bootstrap {
// load the WP testing environment
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
// Load Speed trap.
require_once $this->wp_tests_dir . '/includes/phpunit7/speed-trap-listener.php';
// load WC testing framework
$this->includes();
}

View File

@ -123,23 +123,4 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
$message = $message ? $message : "We're all doomed!";
throw new Exception( $message, $code );
}
/**
* Backport assertNotFalse to PHPUnit 3.6.12 which only runs in PHP 5.2.
*
* @since 2.2
* @param mixed $condition The statement to evaluate as not false.
* @param string $message A message to display if the assertion fails.
*/
public static function assertNotFalse( $condition, $message = '' ) {
if ( version_compare( phpversion(), '5.3', '<' ) ) {
self::assertThat( $condition, self::logicalNot( self::isFalse() ), $message );
} else {
parent::assertNotFalse( $condition, $message );
}
}
}

View File

@ -1,308 +1,7 @@
<?php
// phpcs:disable
/**
* A PHPUnit TestListener that exposes your slowest running tests by outputting
* results directly to the console.
*/
class SpeedTrapListener implements PHPUnit_Framework_TestListener {
/**
* Internal tracking for test suites.
*
* Increments as more suites are run, then decremented as they finish. All
* suites have been run when returns to 0.
*
* @var integer
*/
protected $suites = 0;
/**
* Time in milliseconds at which a test will be considered "slow" and be
* reported by this listener.
*
* @var int
*/
protected $slowThreshold;
/**
* Number of tests to report on for slowness.
*
* @var int
*/
protected $reportLength;
/**
* Collection of slow tests.
*
* @var array
*/
protected $slow = array();
/**
* Construct a new instance.
*
* @param array $options
*/
public function __construct( array $options = array() ) {
$this->loadOptions( $options );
}
/**
* An error occurred.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) {
}
/**
* A warning occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_Warning $e
* @param float $time
* @since Method available since Release 5.1.0
*/
public function addWarning( PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time ) {
}
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) {
}
/**
* Incomplete test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
}
/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @since Method available since Release 4.0.0
*/
public function addRiskyTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
}
/**
* Skipped test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) {
}
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
*/
public function startTest( PHPUnit_Framework_Test $test ) {
}
/**
* A test ended.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest( PHPUnit_Framework_Test $test, $time ) {
if ( ! $test instanceof PHPUnit_Framework_TestCase ) {
return;
}
$time = $this->toMilliseconds( $time );
$threshold = $this->getSlowThreshold( $test );
if ( $this->isSlow( $time, $threshold ) ) {
$this->addSlowTest( $test, $time );
}
}
/**
* A test suite started.
*
* @param PHPUnit_Framework_TestSuite $suite
*/
public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) {
$this->suites++;
}
/**
* A test suite ended.
*
* @param PHPUnit_Framework_TestSuite $suite
*/
public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) {
$this->suites--;
if ( 0 === $this->suites && $this->hasSlowTests() ) {
arsort( $this->slow ); // Sort longest running tests to the top
$this->renderHeader();
$this->renderBody();
$this->renderFooter();
}
}
/**
* Whether the given test execution time is considered slow.
*
* @param int $time Test execution time in milliseconds
* @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
* @return bool
*/
protected function isSlow( $time, $slowThreshold ) {
return $time >= $slowThreshold;
}
/**
* Stores a test as slow.
*
* @param PHPUnit_Framework_TestCase $test
* @param int $time Test execution time in milliseconds
*/
protected function addSlowTest( PHPUnit_Framework_TestCase $test, $time ) {
$label = $this->makeLabel( $test );
$this->slow[ $label ] = $time;
}
/**
* Whether at least one test has been considered slow.
*
* @return bool
*/
protected function hasSlowTests() {
return ! empty( $this->slow );
}
/**
* Convert PHPUnit's reported test time (microseconds) to milliseconds.
*
* @param float $time
* @return int
*/
protected function toMilliseconds( $time ) {
return (int) round( $time * 1000 );
}
/**
* Label for describing a test.
*
* @param PHPUnit_Framework_TestCase $test
* @return string
*/
protected function makeLabel( PHPUnit_Framework_TestCase $test ) {
return sprintf( '%s:%s', get_class( $test ), $test->getName() );
}
/**
* Calculate number of slow tests to report about.
*
* @return int
*/
protected function getReportLength() {
return min( count( $this->slow ), $this->reportLength );
}
/**
* Find how many slow tests occurred that won't be shown due to list length.
*
* @return int Number of hidden slow tests
*/
protected function getHiddenCount() {
$total = count( $this->slow );
$showing = $this->getReportLength( $this->slow );
$hidden = 0;
if ( $total > $showing ) {
$hidden = $total - $showing;
}
return $hidden;
}
/**
* Renders slow test report header.
*/
protected function renderHeader() {
echo sprintf( "\n\nYou should really fix these slow tests (>%sms)...\n", $this->slowThreshold );
}
/**
* Renders slow test report body.
*/
protected function renderBody() {
$slowTests = $this->slow;
$length = $this->getReportLength( $slowTests );
for ( $i = 1; $i <= $length; ++$i ) {
$label = key( $slowTests );
$time = array_shift( $slowTests );
echo sprintf( " %s. %sms to run %s\n", $i, $time, $label );
}
}
/**
* Renders slow test report footer.
*/
protected function renderFooter() {
if ( $hidden = $this->getHiddenCount( $this->slow ) ) {
echo sprintf( '...and there %s %s more above your threshold hidden from view', $hidden == 1 ? 'is' : 'are', $hidden );
}
}
/**
* Populate options into class internals.
*
* @param array $options
*/
protected function loadOptions( array $options ) {
$this->slowThreshold = isset( $options['slowThreshold'] ) ? $options['slowThreshold'] : 500;
$this->reportLength = isset( $options['reportLength'] ) ? $options['reportLength'] : 10;
}
/**
* Get slow test threshold for given test. A TestCase can override the
* suite-wide slow threshold by using the annotation @slowThreshold with
* the threshold value in milliseconds.
*
* The following test will only be considered slow when its execution time
* reaches 5000ms (5 seconds):
*
* <code>
*
* @slowThreshold 5000
* public function testLongRunningProcess() {}
* </code>
*
* @param PHPUnit_Framework_TestCase $test
* @return int
*/
protected function getSlowThreshold( PHPUnit_Framework_TestCase $test ) {
$ann = $test->getAnnotations();
return isset( $ann['method']['slowThreshold'][0] ) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
}
}
class WC_SpeedTrapListener extends SpeedTrapListener {}