Skip to content

Commit 0a54d9c

Browse files
authored
Merge pull request google#189 from MarioBlazek/phpunit_forward_compatibility_layer
PHPUnit forward compatibility layer
2 parents dca379d + 28b6774 commit 0a54d9c

File tree

8 files changed

+41
-14
lines changed

8 files changed

+41
-14
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dist: trusty
2+
13
language: php
24

35
sudo: false

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": ">=5.5"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^4.8"
16+
"phpunit/phpunit": "^4.8.35|^5.7|^6.0"
1717
},
1818
"autoload": {
1919
"psr-4": {
@@ -24,5 +24,8 @@
2424
"branch-alias": {
2525
"dev-master": "1.1.x-dev"
2626
}
27+
},
28+
"scripts": {
29+
"test": "@php vendor/bin/phpunit --colors=always"
2730
}
2831
}

tests/ReCaptcha/ReCaptchaTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
namespace ReCaptcha;
2828

29-
class ReCaptchaTest extends \PHPUnit_Framework_TestCase
29+
use PHPUnit\Framework\TestCase;
30+
31+
class ReCaptchaTest extends TestCase
3032
{
3133

3234
/**
@@ -59,7 +61,10 @@ public function testVerifyReturnsErrorOnMissingResponse()
5961

6062
public function testVerifyReturnsResponse()
6163
{
62-
$method = $this->getMock('\\ReCaptcha\\RequestMethod', array('submit'));
64+
$method = $this->getMockBuilder(\ReCaptcha\RequestMethod::class)
65+
->disableOriginalConstructor()
66+
->setMethods(array('submit'))
67+
->getMock();
6368
$method->expects($this->once())
6469
->method('submit')
6570
->with($this->callback(function ($params) {

tests/ReCaptcha/RequestMethod/CurlPostTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
namespace ReCaptcha\RequestMethod;
2828

2929
use \ReCaptcha\RequestParameters;
30+
use PHPUnit\Framework\TestCase;
3031

31-
class CurlPostTest extends \PHPUnit_Framework_TestCase
32+
class CurlPostTest extends TestCase
3233
{
3334

3435
protected function setUp()
@@ -42,8 +43,10 @@ protected function setUp()
4243

4344
public function testSubmit()
4445
{
45-
$curl = $this->getMock('\\ReCaptcha\\RequestMethod\\Curl',
46-
array('init', 'setoptArray', 'exec', 'close'));
46+
$curl = $this->getMockBuilder(\ReCaptcha\RequestMethod\Curl::class)
47+
->disableOriginalConstructor()
48+
->setMethods(array('init', 'setoptArray', 'exec', 'close'))
49+
->getMock();
4750
$curl->expects($this->once())
4851
->method('init')
4952
->willReturn(new \stdClass);

tests/ReCaptcha/RequestMethod/PostTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727
namespace ReCaptcha\RequestMethod;
2828

2929
use ReCaptcha\RequestParameters;
30+
use PHPUnit\Framework\TestCase;
3031

31-
class PostTest extends \PHPUnit_Framework_TestCase
32+
class PostTest extends TestCase
3233
{
3334
public static $assert = null;
3435
protected $parameters = null;

tests/ReCaptcha/RequestMethod/SocketPostTest.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@
2727
namespace ReCaptcha\RequestMethod;
2828

2929
use ReCaptcha\RequestParameters;
30+
use PHPUnit\Framework\TestCase;
3031

31-
class SocketPostTest extends \PHPUnit_Framework_TestCase
32+
class SocketPostTest extends TestCase
3233
{
33-
3434
public function testSubmitSuccess()
3535
{
36-
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'));
36+
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
37+
->disableOriginalConstructor()
38+
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
39+
->getMock();
3740
$socket->expects($this->once())
3841
->method('fsockopen')
3942
->willReturn(true);
@@ -56,7 +59,10 @@ public function testSubmitSuccess()
5659

5760
public function testSubmitBadResponse()
5861
{
59-
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'));
62+
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
63+
->disableOriginalConstructor()
64+
->setMethods(array('fsockopen', 'fwrite', 'fgets', 'feof', 'fclose'))
65+
->getMock();
6066
$socket->expects($this->once())
6167
->method('fsockopen')
6268
->willReturn(true);
@@ -79,7 +85,10 @@ public function testSubmitBadResponse()
7985

8086
public function testSubmitBadRequest()
8187
{
82-
$socket = $this->getMock('\\ReCaptcha\\RequestMethod\\Socket', array('fsockopen'));
88+
$socket = $this->getMockBuilder(\ReCaptcha\RequestMethod\Socket::class)
89+
->disableOriginalConstructor()
90+
->setMethods(array('fsockopen'))
91+
->getMock();
8392
$socket->expects($this->once())
8493
->method('fsockopen')
8594
->willReturn(false);

tests/ReCaptcha/RequestParametersTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
namespace ReCaptcha;
2828

29-
class RequestParametersTest extends \PHPUnit_Framework_TestCase
29+
use PHPUnit\Framework\TestCase;
30+
31+
class RequestParametersTest extends Testcase
3032
{
3133

3234
public function provideValidData()

tests/ReCaptcha/ResponseTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626

2727
namespace ReCaptcha;
2828

29-
class ResponseTest extends \PHPUnit_Framework_TestCase
29+
use PHPUnit\Framework\TestCase;
30+
31+
class ResponseTest extends TestCase
3032
{
3133

3234
/**

0 commit comments

Comments
 (0)