File: Modernize-PHPUnit-syntax.patch

package info (click to toggle)
google-recaptcha 1.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 436 kB
  • sloc: php: 1,115; makefile: 9
file content (124 lines) | stat: -rw-r--r-- 4,627 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Thu, 6 Mar 2025 13:54:54 +0100
Subject: Modernize PHPUnit syntax

---
 tests/ReCaptcha/ReCaptchaTest.php                | 7 +++----
 tests/ReCaptcha/RequestMethod/SocketPostTest.php | 6 +++---
 tests/ReCaptcha/RequestParametersTest.php        | 9 +++------
 tests/ReCaptcha/ResponseTest.php                 | 5 ++---
 4 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/tests/ReCaptcha/ReCaptchaTest.php b/tests/ReCaptcha/ReCaptchaTest.php
index 886d187..cc5bb03 100644
--- a/tests/ReCaptcha/ReCaptchaTest.php
+++ b/tests/ReCaptcha/ReCaptchaTest.php
@@ -34,13 +34,12 @@
 
 namespace ReCaptcha;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class ReCaptchaTest extends TestCase
 {
-    /**
-     * @dataProvider invalidSecretProvider
-     */
+    #[DataProvider('invalidSecretProvider')]
     public function testExceptionThrownOnInvalidSecret($invalid)
     {
         $this->expectException(\RuntimeException::class);
@@ -76,7 +75,7 @@ class ReCaptchaTest extends TestCase
             ->with($this->callback(function ($params) {
                 return true;
             }))
-            ->will($this->returnValue($responseJson));
+            ->willReturn($responseJson);
         return $method;
     }
 
diff --git a/tests/ReCaptcha/RequestMethod/SocketPostTest.php b/tests/ReCaptcha/RequestMethod/SocketPostTest.php
index 9becf70..f927b4f 100644
--- a/tests/ReCaptcha/RequestMethod/SocketPostTest.php
+++ b/tests/ReCaptcha/RequestMethod/SocketPostTest.php
@@ -55,7 +55,7 @@ class SocketPostTest extends TestCase
                 ->willReturn("HTTP/1.0 200 OK\n\nRESPONSEBODY");
         $socket->expects($this->exactly(2))
                 ->method('feof')
-                ->will($this->onConsecutiveCalls(false, true));
+                ->willReturn(false, true);
         $socket->expects($this->once())
                 ->method('fclose')
                 ->willReturn(true);
@@ -82,7 +82,7 @@ class SocketPostTest extends TestCase
                 ->willReturn("HTTP/1.0 200 OK\n\nRESPONSEBODY");
         $socket->expects($this->exactly(2))
                 ->method('feof')
-                ->will($this->onConsecutiveCalls(false, true));
+                ->willReturn(false, true);
         $socket->expects($this->once())
                 ->method('fclose')
                 ->willReturn(true);
@@ -107,7 +107,7 @@ class SocketPostTest extends TestCase
                 ->willReturn("HTTP/1.0 500 NOPEn\\nBOBBINS");
         $socket->expects($this->exactly(2))
                 ->method('feof')
-                ->will($this->onConsecutiveCalls(false, true));
+                ->willReturn(false, true);
         $socket->expects($this->once())
                 ->method('fclose')
                 ->willReturn(true);
diff --git a/tests/ReCaptcha/RequestParametersTest.php b/tests/ReCaptcha/RequestParametersTest.php
index 84f45c4..c8c7b38 100644
--- a/tests/ReCaptcha/RequestParametersTest.php
+++ b/tests/ReCaptcha/RequestParametersTest.php
@@ -34,6 +34,7 @@
 
 namespace ReCaptcha;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class RequestParametersTest extends Testcase
@@ -50,18 +51,14 @@ class RequestParametersTest extends Testcase
         );
     }
 
-    /**
-     * @dataProvider provideValidData
-     */
+    #[DataProvider('provideValidData')]
     public function testToArray($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
     {
         $params = new RequestParameters($secret, $response, $remoteIp, $version);
         $this->assertEquals($params->toArray(), $expectedArray);
     }
 
-    /**
-     * @dataProvider provideValidData
-     */
+    #[DataProvider('provideValidData')]
     public function testToQueryString($secret, $response, $remoteIp, $version, $expectedArray, $expectedQuery)
     {
         $params = new RequestParameters($secret, $response, $remoteIp, $version);
diff --git a/tests/ReCaptcha/ResponseTest.php b/tests/ReCaptcha/ResponseTest.php
index 13092d2..841d833 100644
--- a/tests/ReCaptcha/ResponseTest.php
+++ b/tests/ReCaptcha/ResponseTest.php
@@ -34,13 +34,12 @@
 
 namespace ReCaptcha;
 
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 
 class ResponseTest extends TestCase
 {
-    /**
-     * @dataProvider provideJson
-     */
+    #[DataProvider('provideJson')]
     public function testFromJson($json, $success, $errorCodes, $hostname, $challengeTs, $apkPackageName, $score, $action)
     {
         $response = Response::fromJson($json);