Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Commit 6397e67

Browse files
Cherrypick test fixes (DataDog#127)
Unit tests support for all PHP vesrions Co-authored-by: Lewis Cowles <[email protected]>
1 parent d45fc38 commit 6397e67

8 files changed

+32
-18
lines changed

Diff for: .circleci/config.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2 # use CircleCI 2.0
22

3-
x-dockerbuild-7: &dockerbuild-7
3+
x-dockerbuild-phpdbg: &dockerbuild-phpdbg
44
steps:
55
- checkout
66
- run: sudo docker-php-ext-install sockets
@@ -19,16 +19,28 @@ x-dockerbuild-5: &dockerbuild-5
1919
- run: composer lint
2020

2121
jobs:
22+
test-8.0:
23+
<<: *dockerbuild-phpdbg
24+
docker:
25+
- image: circleci/php:8.0-node-browsers
26+
test-7.4:
27+
<<: *dockerbuild-phpdbg
28+
docker:
29+
- image: circleci/php:7.4-node-browsers
30+
test-7.3:
31+
<<: *dockerbuild-phpdbg
32+
docker:
33+
- image: circleci/php:7.3-node-browsers
2234
test-7.2:
23-
<<: *dockerbuild-7
35+
<<: *dockerbuild-phpdbg
2436
docker:
2537
- image: circleci/php:7.2-node-browsers
2638
test-7.1:
27-
<<: *dockerbuild-7
39+
<<: *dockerbuild-phpdbg
2840
docker:
2941
- image: circleci/php:7.1-node-browsers
3042
test-7.0:
31-
<<: *dockerbuild-7
43+
<<: *dockerbuild-phpdbg
3244
docker:
3345
- image: circleci/php:7.0-node-browsers
3446
test-5.6:
@@ -40,6 +52,9 @@ workflows:
4052
version: 2
4153
check_compile:
4254
jobs:
55+
- test-8.0
56+
- test-7.4
57+
- test-7.3
4358
- test-7.2
4459
- test-7.1
4560
- test-7.0

Diff for: composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"sort-packages": true
5050
},
5151
"require-dev": {
52-
"phpunit/phpunit": "5.7.27",
52+
"yoast/phpunit-polyfills": "^1.0.1",
5353
"squizlabs/php_codesniffer": "^3.3"
5454
},
5555
"scripts": {

Diff for: tests/TestHelpers/CurlSpyTestCase.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace DataDog\TestHelpers;
44

5-
use PHPUnit\Framework\TestCase;
5+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
66

77
$curlSpy = new CurlSpy();
88

@@ -11,13 +11,12 @@ class CurlSpyTestCase extends TestCase
1111
/**
1212
* Set up a spy object to capture calls to built in curl functions
1313
*/
14-
protected function setUp()
14+
protected function set_up()
1515
{
1616
global $curlSpy;
1717

1818
$curlSpy = new CurlSpy();
19-
20-
parent::setUp();
19+
parent::set_up();
2120
}
2221

2322
/**

Diff for: tests/TestHelpers/SocketSpyTestCase.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace DataDog\TestHelpers;
44

55
use DataDog\DogStatsd;
6-
use PHPUnit\Framework\TestCase;
6+
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
77

88
/**
99
* Making this variable global to this file is necessary for interacting with
@@ -24,13 +24,13 @@ class SocketSpyTestCase extends TestCase
2424
/**
2525
* Set up a spy object to capture calls to global built in socket functions
2626
*/
27-
protected function setUp()
27+
protected function set_up()
2828
{
2929
global $socketSpy;
3030

3131
$socketSpy = new SocketSpy();
3232

33-
parent::setUp();
33+
parent::set_up();
3434
}
3535

3636
/**

Diff for: tests/UnitTests/BatchedDogStatsdTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
class BatchedDogStatsdTest extends SocketSpyTestCase
1010
{
11-
protected function setUp()
11+
protected function set_up()
1212
{
13-
parent::setUp();
13+
parent::set_up();
1414

1515
// Flush the buffer to reset state for next test
1616
BatchedDogStatsd::$maxBufferLength = 50;

Diff for: tests/UnitTests/DogStatsd/SocketsTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
class SocketsTest extends SocketSpyTestCase
1111
{
12-
public function setUp()
12+
public function set_up()
1313
{
14-
parent::setUp();
14+
parent::set_up();
1515

1616
// Reset the stubs for mt_rand() and mt_getrandmax()
1717
global $mt_rand_stub_return_value;

Diff for: tests/curl_and_error_log_function_stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function curl_init($url = null)
2424

2525
$curlSpy->curlInitWasCalledWithArg($url);
2626

27-
$resource = fopen('/dev/null', 'r');
27+
$resource = tmpfile();
2828

2929
$curlSpy->curlInitDidReturn($resource);
3030

Diff for: tests/socket_function_stubs.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function socket_create($domain, $type, $protocol)
2929

3030
// A PHP resource of unimportance, useful primarily to assert that our stubs
3131
// of the global socket functions return or take a deterministic value.
32-
$resource = fopen('/dev/null', 'r');
32+
$resource = tmpfile();
3333

3434
$socketSpy->socketCreateDidReturn($resource);
3535

0 commit comments

Comments
 (0)