Skip to content

Commit 522c829

Browse files
authored
Merge pull request php-curl-class#688 from zachborboa/master
Add option to skip running slower tests
2 parents 8340a4c + 31a65e2 commit 522c829

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
class CurlTest extends \PHPUnit\Framework\TestCase
1212
{
13+
private $skip_slow_tests;
14+
15+
protected function setUp(): void
16+
{
17+
$this->skip_slow_tests = in_array(getenv('PHP_CURL_CLASS_SKIP_SLOW_TESTS'), ['1', 'y', 'Y']);
18+
}
19+
1320
public function testExtensionsLoaded()
1421
{
1522
$this->assertTrue(extension_loaded('curl'));
@@ -813,6 +820,10 @@ public function testDownloadErrorDeleteTemporaryFile()
813820

814821
public function testDownloadCallbackError()
815822
{
823+
if ($this->skip_slow_tests) {
824+
$this->markTestSkipped();
825+
}
826+
816827
$download_before_send_called = false;
817828
$download_callback_called = false;
818829
$curl = new Curl();
@@ -1102,6 +1113,10 @@ public function testMultipleCookieResponse()
11021113

11031114
public function testDefaultTimeout()
11041115
{
1116+
if ($this->skip_slow_tests) {
1117+
$this->markTestSkipped();
1118+
}
1119+
11051120
$test = new Test('8001');
11061121
$test->server('timeout', 'GET', [
11071122
'seconds' => '31',
@@ -1115,6 +1130,10 @@ public function testDefaultTimeout()
11151130

11161131
public function testTimeoutError()
11171132
{
1133+
if ($this->skip_slow_tests) {
1134+
$this->markTestSkipped();
1135+
}
1136+
11181137
$test = new Test('8002');
11191138
$test->curl->setTimeout(5);
11201139
$test->server('timeout', 'GET', [
@@ -1129,6 +1148,10 @@ public function testTimeoutError()
11291148

11301149
public function testTimeout()
11311150
{
1151+
if ($this->skip_slow_tests) {
1152+
$this->markTestSkipped();
1153+
}
1154+
11321155
$test = new Test('8003');
11331156
$test->curl->setTimeout(10);
11341157
$test->server('timeout', 'GET', [
@@ -1144,6 +1167,10 @@ public function testTimeout()
11441167

11451168
public function testError()
11461169
{
1170+
if ($this->skip_slow_tests) {
1171+
$this->markTestSkipped();
1172+
}
1173+
11471174
$test = new Test('8004');
11481175
$test->curl->get(Test::ERROR_URL);
11491176
$this->assertTrue($test->curl->error);
@@ -2928,6 +2955,10 @@ public function testSuccessCallback()
29282955

29292956
public function testErrorCallback()
29302957
{
2958+
if ($this->skip_slow_tests) {
2959+
$this->markTestSkipped();
2960+
}
2961+
29312962
$before_send_called = false;
29322963
$success_called = false;
29332964
$error_called = false;

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
class MultiCurlTest extends \PHPUnit\Framework\TestCase
1010
{
11+
private $skip_slow_tests;
12+
13+
protected function setUp(): void
14+
{
15+
$this->skip_slow_tests = in_array(getenv('PHP_CURL_CLASS_SKIP_SLOW_TESTS'), ['1', 'y', 'Y']);
16+
}
17+
1118
public function testMultiCurlCallback()
1219
{
1320
$delete_before_send_called = false;
@@ -370,6 +377,10 @@ public function testMultiCurlCallback()
370377

371378
public function testMultiCurlCallbackError()
372379
{
380+
if ($this->skip_slow_tests) {
381+
$this->markTestSkipped();
382+
}
383+
373384
$delete_before_send_called = false;
374385
$delete_success_called = false;
375386
$delete_error_called = false;
@@ -1168,6 +1179,10 @@ public function testCurlCallback()
11681179

11691180
public function testCurlCallbackError()
11701181
{
1182+
if ($this->skip_slow_tests) {
1183+
$this->markTestSkipped();
1184+
}
1185+
11711186
$multi_curl = new MultiCurl();
11721187

11731188
$delete_before_send_called = false;
@@ -2758,6 +2773,10 @@ public function testDownloadErrorDeleteTemporaryFile()
27582773

27592774
public function testDownloadCallbackError()
27602775
{
2776+
if ($this->skip_slow_tests) {
2777+
$this->markTestSkipped();
2778+
}
2779+
27612780
$download_before_send_called = false;
27622781
$download_callback_called = false;
27632782
$multi_curl = new MultiCurl();
@@ -3710,6 +3729,10 @@ public function testSetRateLimitUnits()
37103729

37113730
public function testSetRateLimitPerSecond1()
37123731
{
3732+
if ($this->skip_slow_tests) {
3733+
$this->markTestSkipped();
3734+
}
3735+
37133736
// R0--|
37143737
// R1--|
37153738
// W---------------|
@@ -3779,6 +3802,10 @@ public function testSetRateLimitPerSecond1()
37793802

37803803
public function testSetRateLimitPerSecond2()
37813804
{
3805+
if ($this->skip_slow_tests) {
3806+
$this->markTestSkipped();
3807+
}
3808+
37823809
// R0--|
37833810
// R1------|
37843811
// W-----------|
@@ -3848,6 +3875,10 @@ public function testSetRateLimitPerSecond2()
38483875

38493876
public function testSetRateLimitPerSecond3()
38503877
{
3878+
if ($this->skip_slow_tests) {
3879+
$this->markTestSkipped();
3880+
}
3881+
38513882
// R0------|
38523883
// R1------------------|
38533884
// R2------|
@@ -3915,6 +3946,10 @@ public function testSetRateLimitPerSecond3()
39153946

39163947
public function testSetRateLimitPerSecond4()
39173948
{
3949+
if ($this->skip_slow_tests) {
3950+
$this->markTestSkipped();
3951+
}
3952+
39183953
// R0------|
39193954
// R1----------------------------------|
39203955
// R2----------|
@@ -3982,6 +4017,10 @@ public function testSetRateLimitPerSecond4()
39824017

39834018
public function testSetRateLimitPerSecond5()
39844019
{
4020+
if ($this->skip_slow_tests) {
4021+
$this->markTestSkipped();
4022+
}
4023+
39854024
// R0--------------------------|
39864025
// R1--------------------------|
39874026
// R2------|
@@ -4050,6 +4089,10 @@ public function testSetRateLimitPerSecond5()
40504089

40514090
public function testSetRateLimitPerSecond6()
40524091
{
4092+
if ($this->skip_slow_tests) {
4093+
$this->markTestSkipped();
4094+
}
4095+
40534096
// R0--------------------------|
40544097
// R1--------------------------|
40554098
// R2--------------|
@@ -4118,6 +4161,10 @@ public function testSetRateLimitPerSecond6()
41184161

41194162
public function testSetRateLimitPerSecond7()
41204163
{
4164+
if ($this->skip_slow_tests) {
4165+
$this->markTestSkipped();
4166+
}
4167+
41214168
// R0------|
41224169
// R1----------------------------------------------|
41234170
// R2----------------------|
@@ -4194,6 +4241,10 @@ public function testSetRateLimitPerSecond7()
41944241

41954242
public function testSetRateLimitPerSecond8()
41964243
{
4244+
if ($this->skip_slow_tests) {
4245+
$this->markTestSkipped();
4246+
}
4247+
41974248
// R0------------------------------|
41984249
// R1----------------------------------------------|
41994250
// R2--------------------------|
@@ -4270,6 +4321,10 @@ public function testSetRateLimitPerSecond8()
42704321

42714322
public function testSetRateLimitPerSecond9()
42724323
{
4324+
if ($this->skip_slow_tests) {
4325+
$this->markTestSkipped();
4326+
}
4327+
42734328
// R0----------------------------------------------|
42744329
// R1----------------------------------------------|
42754330
// R2--------------------------|
@@ -4346,6 +4401,10 @@ public function testSetRateLimitPerSecond9()
43464401

43474402
public function testSetRateLimitPerSecondOnePerSecond()
43484403
{
4404+
if ($this->skip_slow_tests) {
4405+
$this->markTestSkipped();
4406+
}
4407+
43494408
$request_stats = [];
43504409

43514410
$multi_curl = new MultiCurl();
@@ -4380,6 +4439,10 @@ public function testSetRateLimitPerSecondOnePerSecond()
43804439

43814440
public function testSetRateLimitFivePerThirtySecond()
43824441
{
4442+
if ($this->skip_slow_tests) {
4443+
$this->markTestSkipped();
4444+
}
4445+
43834446
$request_stats = [];
43844447

43854448
$multi_curl = new MultiCurl();
@@ -4410,6 +4473,10 @@ public function testSetRateLimitFivePerThirtySecond()
44104473

44114474
public function testSetRateLimitOnePerOneMinute()
44124475
{
4476+
if ($this->skip_slow_tests) {
4477+
$this->markTestSkipped();
4478+
}
4479+
44134480
$request_stats = [];
44144481

44154482
$multi_curl = new MultiCurl();
@@ -4440,6 +4507,10 @@ public function testSetRateLimitOnePerOneMinute()
44404507

44414508
public function testSetRateLimitThreePerOneMinute()
44424509
{
4510+
if ($this->skip_slow_tests) {
4511+
$this->markTestSkipped();
4512+
}
4513+
44434514
$request_stats = [];
44444515

44454516
$multi_curl = new MultiCurl();
@@ -4468,6 +4539,10 @@ public function testSetRateLimitThreePerOneMinute()
44684539

44694540
public function testSetRateLimitThreePerSixtyFiveSeconds()
44704541
{
4542+
if ($this->skip_slow_tests) {
4543+
$this->markTestSkipped();
4544+
}
4545+
44714546
$request_stats = [];
44724547

44734548
$multi_curl = new MultiCurl();
@@ -4496,6 +4571,10 @@ public function testSetRateLimitThreePerSixtyFiveSeconds()
44964571

44974572
public function testSetRateLimitTenPerTwoMinutes()
44984573
{
4574+
if ($this->skip_slow_tests) {
4575+
$this->markTestSkipped();
4576+
}
4577+
44994578
$request_stats = [];
45004579

45014580
$multi_curl = new MultiCurl();

tests/ci.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ phpunit_v8_1_shim() {
2424
remove_expectWarning
2525
}
2626

27+
php_v7_0_shim() {
28+
# -protected function setUp(): void
29+
# +protected function setUp()
30+
find='protected function setUp(): void'
31+
replace='protected function setUp()'
32+
sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"*
33+
}
34+
2735
set -x
2836

2937
composer self-update
@@ -76,6 +84,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then
7684
phpunit_v8_1_shim
7785
fi
7886

87+
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then
88+
php_v7_0_shim
89+
fi
90+
7991
# Run tests.
8092
"${phpunit_to_use}" --version
8193
"${phpunit_to_use}" \

tests/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ phpunit_v8_1_shim() {
2424
remove_expectWarning
2525
}
2626

27+
php_v7_0_shim() {
28+
# -protected function setUp(): void
29+
# +protected function setUp()
30+
find='protected function setUp(): void'
31+
replace='protected function setUp()'
32+
sed -i'' -e"s/${find}/${replace}/" "./PHPCurlClass/PHP"*
33+
}
34+
2735
set -x
2836

2937
# Use composer's phpunit and phpcs by adding composer bin directory to the path environment variable.
@@ -73,6 +81,10 @@ elif [[ "${phpunit_version}" == "8.1."* ]]; then
7381
phpunit_v8_1_shim
7482
fi
7583

84+
if [[ "${CI_PHP_VERSION}" == "7.0" ]]; then
85+
php_v7_0_shim
86+
fi
87+
7688
# Run tests.
7789
extra_args="${@}"
7890
"${phpunit_to_use}" --version

0 commit comments

Comments
 (0)