Skip to content

Commit 9653520

Browse files
committed
Update for PHPUnit 10
1 parent 2066a6e commit 9653520

File tree

7 files changed

+29
-47
lines changed

7 files changed

+29
-47
lines changed

phpunit.xml.dist

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.4/phpunit.xsd"
4-
colors="true"
5-
verbose="true"
6-
bootstrap="src/autoload.php">
7-
<testsuites>
8-
<testsuite name="reCAPTCHA Test Suite">
9-
<directory>tests/ReCaptcha/</directory>
10-
</testsuite>
11-
</testsuites>
12-
<filter>
13-
<whitelist>
14-
<directory suffix=".php">src/ReCaptcha/</directory>
15-
</whitelist>
16-
</filter>
17-
<logging>
18-
<log type="coverage-clover" target="build/logs/clover.xml"/>
19-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" colors="true" bootstrap="src/autoload.php" cacheDirectory=".phpunit.cache">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/ReCaptcha/</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/logs/clover.xml"/>
9+
</report>
10+
</coverage>
11+
<testsuites>
12+
<testsuite name="reCAPTCHA Test Suite">
13+
<directory>tests/ReCaptcha/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<logging/>
2017
</phpunit>

tests/ReCaptcha/ReCaptchaTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,16 @@
3838

3939
class ReCaptchaTest extends TestCase
4040
{
41-
4241
/**
43-
* @expectedException \RuntimeException
4442
* @dataProvider invalidSecretProvider
4543
*/
4644
public function testExceptionThrownOnInvalidSecret($invalid)
4745
{
46+
$this->expectException(\RuntimeException::class);
4847
$rc = new ReCaptcha($invalid);
4948
}
5049

51-
public function invalidSecretProvider()
50+
public static function invalidSecretProvider()
5251
{
5352
return array(
5453
array(''),
@@ -71,7 +70,6 @@ private function getMockRequestMethod($responseJson)
7170
{
7271
$method = $this->getMockBuilder(\ReCaptcha\RequestMethod::class)
7372
->disableOriginalConstructor()
74-
->setMethods(array('submit'))
7573
->getMock();
7674
$method->expects($this->any())
7775
->method('submit')

tests/ReCaptcha/RequestMethod/CurlPostTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434

3535
namespace ReCaptcha\RequestMethod;
3636

37-
use \ReCaptcha\ReCaptcha;
38-
use \ReCaptcha\RequestParameters;
37+
use ReCaptcha\ReCaptcha;
38+
use ReCaptcha\RequestParameters;
3939
use PHPUnit\Framework\TestCase;
4040

4141
class CurlPostTest extends TestCase
4242
{
43-
protected function setUp()
43+
protected function setUp(): void
4444
{
4545
if (!extension_loaded('curl')) {
4646
$this->markTestSkipped(
@@ -53,11 +53,10 @@ public function testSubmit()
5353
{
5454
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
5555
->disableOriginalConstructor()
56-
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
5756
->getMock();
5857
$curl->expects($this->once())
5958
->method('init')
60-
->willReturn(new \stdClass);
59+
->willReturn(new \stdClass());
6160
$curl->expects($this->once())
6261
->method('setoptArray')
6362
->willReturn(true);
@@ -78,12 +77,11 @@ public function testOverrideSiteVerifyUrl()
7877

7978
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
8079
->disableOriginalConstructor()
81-
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
8280
->getMock();
8381
$curl->expects($this->once())
8482
->method('init')
8583
->with($url)
86-
->willReturn(new \stdClass);
84+
->willReturn(new \stdClass());
8785
$curl->expects($this->once())
8886
->method('setoptArray')
8987
->willReturn(true);
@@ -102,11 +100,10 @@ public function testConnectionFailureReturnsError()
102100
{
103101
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
104102
->disableOriginalConstructor()
105-
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
106103
->getMock();
107104
$curl->expects($this->once())
108105
->method('init')
109-
->willReturn(new \stdClass);
106+
->willReturn(new \stdClass());
110107
$curl->expects($this->once())
111108
->method('setoptArray')
112109
->willReturn(true);

tests/ReCaptcha/RequestMethod/PostTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace ReCaptcha\RequestMethod;
3636

37-
use \ReCaptcha\ReCaptcha;
37+
use ReCaptcha\ReCaptcha;
3838
use ReCaptcha\RequestParameters;
3939
use PHPUnit\Framework\TestCase;
4040

@@ -44,12 +44,12 @@ class PostTest extends TestCase
4444
protected $parameters = null;
4545
protected $runcount = 0;
4646

47-
public function setUp()
47+
public function setUp(): void
4848
{
4949
$this->parameters = new RequestParameters('secret', 'response', 'remoteip', 'version');
5050
}
5151

52-
public function tearDown()
52+
public function tearDown(): void
5353
{
5454
self::$assert = null;
5555
}
@@ -111,12 +111,7 @@ public function httpContextOptionsCallback(array $args)
111111
$this->assertEquals($this->parameters->toQueryString(), $options['http']['content']);
112112

113113
$this->assertArrayHasKey('header', $options['http']);
114-
$headers = array(
115-
'Content-type: application/x-www-form-urlencoded',
116-
);
117-
foreach ($headers as $header) {
118-
$this->assertContains($header, $options['http']['header']);
119-
}
114+
$this->assertStringContainsStringIgnoringCase('Content-type: application/x-www-form-urlencoded', $options['http']['header']);
120115
}
121116

122117
public function sslContextOptionsCallback(array $args)

tests/ReCaptcha/RequestMethod/SocketPostTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public function testSubmitSuccess()
4444
{
4545
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
4646
->disableOriginalConstructor()
47-
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
4847
->getMock();
4948
$socket->expects($this->once())
5049
->method('fsockopen')
@@ -70,7 +69,6 @@ public function testOverrideSiteVerifyUrl()
7069
{
7170
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
7271
->disableOriginalConstructor()
73-
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
7472
->getMock();
7573
$socket->expects($this->once())
7674
->method('fsockopen')
@@ -98,7 +96,6 @@ public function testSubmitBadResponse()
9896
{
9997
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
10098
->disableOriginalConstructor()
101-
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
10299
->getMock();
103100
$socket->expects($this->once())
104101
->method('fsockopen')
@@ -124,7 +121,6 @@ public function testConnectionFailureReturnsError()
124121
{
125122
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
126123
->disableOriginalConstructor()
127-
->setMethods(array('fsockopen'))
128124
->getMock();
129125
$socket->expects($this->once())
130126
->method('fsockopen')

tests/ReCaptcha/RequestParametersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
class RequestParametersTest extends Testcase
4040
{
41-
public function provideValidData()
41+
public static function provideValidData()
4242
{
4343
return array(
4444
array('SECRET', 'RESPONSE', 'REMOTEIP', 'VERSION',

tests/ReCaptcha/ResponseTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838

3939
class ResponseTest extends TestCase
4040
{
41-
4241
/**
4342
* @dataProvider provideJson
4443
*/
@@ -54,7 +53,7 @@ public function testFromJson($json, $success, $errorCodes, $hostname, $challenge
5453
$this->assertEquals($action, $response->getAction());
5554
}
5655

57-
public function provideJson()
56+
public static function provideJson()
5857
{
5958
return array(
6059
array(

0 commit comments

Comments
 (0)