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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
|
From 696163addf28bb4e01455254e055a9a75e0ba6c4 Mon Sep 17 00:00:00 2001
From: Fabien Villepinte <fabien.villepinte@gmail.com>
Date: Thu, 14 Dec 2023 12:00:58 +0100
Subject: [PATCH] Allow installation of PHPUnit 8 in order to test with PHP 8.1
and 8.2 (#82)
* Allow installation of PHPUnit 8
* Run the tests with PHP 8.1 and 8.2
---
.github/workflows/tests.yml | 9 ++-------
.gitignore | 1 +
composer.json | 2 +-
tests/Hamcrest/Core/CombinableMatcherTest.php | 5 ++++-
tests/Hamcrest/Core/IsInstanceOfTest.php | 5 ++++-
tests/Hamcrest/Core/SetTest.php | 5 ++++-
tests/Hamcrest/FeatureMatcherTest.php | 5 ++++-
tests/Hamcrest/MatcherAssertTest.php | 5 ++++-
tests/Hamcrest/StringDescriptionTest.php | 5 ++++-
tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php | 5 ++++-
tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php | 5 ++++-
tests/Hamcrest/Text/StringContainsInOrderTest.php | 5 ++++-
tests/Hamcrest/Text/StringContainsTest.php | 5 ++++-
tests/Hamcrest/Text/StringEndsWithTest.php | 5 ++++-
tests/Hamcrest/Text/StringStartsWithTest.php | 5 ++++-
tests/Hamcrest/Xml/HasXPathTest.php | 5 ++++-
16 files changed, 56 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 06255a1b9..f23413216 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
+ php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
name: PHP ${{ matrix.php }}
@@ -26,13 +26,8 @@ jobs:
tools: composer:v2
coverage: none
- - name: Install PHP 7 dependencies
+ - name: Install PHP dependencies
run: composer update --prefer-dist --no-interaction --no-progress
- if: "matrix.php != '8.0'"
-
- - name: Install PHP 8 dependencies
- run: composer update --prefer-dist --no-interaction --no-progress --ignore-platform-reqs
- if: "matrix.php == '8.0'"
- name: Execute tests
run: vendor/bin/phpunit -c tests/phpunit.xml.dist
diff --git a/.gitignore b/.gitignore
index 987e2a253..7611d841f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
composer.lock
+tests/.phpunit.result.cache
vendor
diff --git a/composer.json b/composer.json
index 712ad9655..180f341d8 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
"require-dev": {
"phpunit/php-file-iterator": "^1.4 || ^2.0",
- "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0"
+ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0"
},
"replace": {
diff --git a/tests/Hamcrest/Core/CombinableMatcherTest.php b/tests/Hamcrest/Core/CombinableMatcherTest.php
index 463c75437..ef9418674 100644
--- a/tests/Hamcrest/Core/CombinableMatcherTest.php
+++ b/tests/Hamcrest/Core/CombinableMatcherTest.php
@@ -7,7 +7,10 @@ class CombinableMatcherTest extends \Hamcrest\AbstractMatcherTest
private $_either_3_or_4;
private $_not_3_and_not_4;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_either_3_or_4 = \Hamcrest\Core\CombinableMatcher::either(equalTo(3))->orElse(equalTo(4));
$this->_not_3_and_not_4 = \Hamcrest\Core\CombinableMatcher::both(not(equalTo(3)))->andAlso(not(equalTo(4)));
diff --git a/tests/Hamcrest/Core/IsInstanceOfTest.php b/tests/Hamcrest/Core/IsInstanceOfTest.php
index f74cfdb52..b4fdd04fd 100644
--- a/tests/Hamcrest/Core/IsInstanceOfTest.php
+++ b/tests/Hamcrest/Core/IsInstanceOfTest.php
@@ -7,7 +7,10 @@ class IsInstanceOfTest extends \Hamcrest\AbstractMatcherTest
private $_baseClassInstance;
private $_subClassInstance;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_baseClassInstance = new \Hamcrest\Core\SampleBaseClass('good');
$this->_subClassInstance = new \Hamcrest\Core\SampleSubClass('good');
diff --git a/tests/Hamcrest/Core/SetTest.php b/tests/Hamcrest/Core/SetTest.php
index aa5e4e7be..f00efa4f4 100644
--- a/tests/Hamcrest/Core/SetTest.php
+++ b/tests/Hamcrest/Core/SetTest.php
@@ -7,7 +7,10 @@ class SetTest extends \Hamcrest\AbstractMatcherTest
public static $_classProperty;
public $_instanceProperty;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
self::$_classProperty = null;
unset($this->_instanceProperty);
diff --git a/tests/Hamcrest/FeatureMatcherTest.php b/tests/Hamcrest/FeatureMatcherTest.php
index 1b0230498..dfae872bf 100644
--- a/tests/Hamcrest/FeatureMatcherTest.php
+++ b/tests/Hamcrest/FeatureMatcherTest.php
@@ -34,7 +34,10 @@ class FeatureMatcherTest extends \Hamcrest\AbstractMatcherTest
private $_resultMatcher;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_resultMatcher = $this->_resultMatcher();
}
diff --git a/tests/Hamcrest/MatcherAssertTest.php b/tests/Hamcrest/MatcherAssertTest.php
index dc12fba54..e34919869 100644
--- a/tests/Hamcrest/MatcherAssertTest.php
+++ b/tests/Hamcrest/MatcherAssertTest.php
@@ -6,7 +6,10 @@
class MatcherAssertTest extends TestCase
{
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
\Hamcrest\MatcherAssert::resetCount();
}
diff --git a/tests/Hamcrest/StringDescriptionTest.php b/tests/Hamcrest/StringDescriptionTest.php
index ed716d13e..b42b9b469 100644
--- a/tests/Hamcrest/StringDescriptionTest.php
+++ b/tests/Hamcrest/StringDescriptionTest.php
@@ -23,7 +23,10 @@ class StringDescriptionTest extends TestCase
private $_description;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_description = new \Hamcrest\StringDescription();
}
diff --git a/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php b/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php
index 27ad338b7..42444489f 100644
--- a/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php
+++ b/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php
@@ -6,7 +6,10 @@ class IsEqualIgnoringWhiteSpaceTest extends \Hamcrest\AbstractMatcherTest
private $_matcher;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_matcher = \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace(
"Hello World how\n are we? "
diff --git a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
index 73023007b..8b4463a9e 100644
--- a/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
+++ b/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php
@@ -8,7 +8,10 @@ class StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
private $_stringContains;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase(
strtolower(self::EXCERPT)
diff --git a/tests/Hamcrest/Text/StringContainsInOrderTest.php b/tests/Hamcrest/Text/StringContainsInOrderTest.php
index 4c465b29d..adb8658f4 100644
--- a/tests/Hamcrest/Text/StringContainsInOrderTest.php
+++ b/tests/Hamcrest/Text/StringContainsInOrderTest.php
@@ -6,7 +6,10 @@ class StringContainsInOrderTest extends \Hamcrest\AbstractMatcherTest
private $_m;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_m = \Hamcrest\Text\StringContainsInOrder::stringContainsInOrder(array('a', 'b', 'c'));
}
diff --git a/tests/Hamcrest/Text/StringContainsTest.php b/tests/Hamcrest/Text/StringContainsTest.php
index bf4afa3c9..814c1ca1b 100644
--- a/tests/Hamcrest/Text/StringContainsTest.php
+++ b/tests/Hamcrest/Text/StringContainsTest.php
@@ -8,7 +8,10 @@ class StringContainsTest extends \Hamcrest\AbstractMatcherTest
private $_stringContains;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_stringContains = \Hamcrest\Text\StringContains::containsString(self::EXCERPT);
}
diff --git a/tests/Hamcrest/Text/StringEndsWithTest.php b/tests/Hamcrest/Text/StringEndsWithTest.php
index 9a30f9520..46177f464 100644
--- a/tests/Hamcrest/Text/StringEndsWithTest.php
+++ b/tests/Hamcrest/Text/StringEndsWithTest.php
@@ -8,7 +8,10 @@ class StringEndsWithTest extends \Hamcrest\AbstractMatcherTest
private $_stringEndsWith;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_stringEndsWith = \Hamcrest\Text\StringEndsWith::endsWith(self::EXCERPT);
}
diff --git a/tests/Hamcrest/Text/StringStartsWithTest.php b/tests/Hamcrest/Text/StringStartsWithTest.php
index 3be201f1a..f0eb14b7e 100644
--- a/tests/Hamcrest/Text/StringStartsWithTest.php
+++ b/tests/Hamcrest/Text/StringStartsWithTest.php
@@ -8,7 +8,10 @@ class StringStartsWithTest extends \Hamcrest\AbstractMatcherTest
private $_stringStartsWith;
- protected function setUp()
+ /**
+ * @before
+ */
+ protected function setUpTest()
{
$this->_stringStartsWith = \Hamcrest\Text\StringStartsWith::startsWith(self::EXCERPT);
}
diff --git a/tests/Hamcrest/Xml/HasXPathTest.php b/tests/Hamcrest/Xml/HasXPathTest.php
index 677488716..3db5e46e0 100644
--- a/tests/Hamcrest/Xml/HasXPathTest.php
+++ b/tests/Hamcrest/Xml/HasXPathTest.php
@@ -7,7 +7,10 @@ class HasXPathTest extends \Hamcrest\AbstractMatcherTest
protected static $doc;
protected static $html;
- public static function setUpBeforeClass()
+ /**
+ * @beforeClass
+ */
+ public static function setUpBeforeClassTest()
{
self::$xml = <<<XML
<?xml version="1.0"?>
From 103d1443ec6c552ff1c15e2bddbb9ce7c96528be Mon Sep 17 00:00:00 2001
From: Fabien Villepinte <fabien.villepinte@gmail.com>
Date: Fri, 3 May 2024 15:45:43 +0200
Subject: [PATCH] Fix all PHPUnit's deprecations
---
.github/workflows/tests.yml | 14 +++++++++++++-
tests/Hamcrest/UtilTest.php | 23 +++++++++++++++--------
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index f23413216..68b483587 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -10,7 +10,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
+ php:
+ - '5.3'
+ - '5.4'
+ - '5.5'
+ - '5.6'
+ - '7.0'
+ - '7.1'
+ - '7.2'
+ - '7.3'
+ - '7.4'
+ - '8.0'
+ - '8.1'
+ - '8.2'
name: PHP ${{ matrix.php }}
diff --git a/tests/Hamcrest/UtilTest.php b/tests/Hamcrest/UtilTest.php
index 7248978c7..1fec63eed 100644
--- a/tests/Hamcrest/UtilTest.php
+++ b/tests/Hamcrest/UtilTest.php
@@ -28,21 +28,28 @@ public function testCheckAllAreMatchersAcceptsMatchers()
));
}
- /**
- * @expectedException InvalidArgumentException
- */
public function testCheckAllAreMatchersFailsForPrimitive()
{
- \Hamcrest\Util::checkAllAreMatchers(array(
- new \Hamcrest\Text\MatchesPattern('/fo+/'),
- 'foo',
- ));
+ $exceptionThrown = false;
+ try {
+ \Hamcrest\Util::checkAllAreMatchers(array(
+ new \Hamcrest\Text\MatchesPattern('/fo+/'),
+ 'foo',
+ ));
+ } catch (\InvalidArgumentException $exception) {
+ $exceptionThrown = true;
+ }
+
+ $this->assertTrue(
+ $exceptionThrown,
+ 'Failed asserting that exception of type "InvalidArgumentException" is thrown.'
+ );
}
private function callAndAssertCreateMatcherArray($items)
{
$matchers = \Hamcrest\Util::createMatcherArray($items);
- $this->assertInternalType('array', $matchers);
+ $this->assertTrue(is_array($matchers), sprintf('Type "array" expected, but got "%s" instead', gettype($matchers)));
$this->assertSameSize($items, $matchers);
foreach ($matchers as $matcher) {
$this->assertInstanceOf('\Hamcrest\Matcher', $matcher);
From e3b7bfcda4bc88f94e7f37f2a3a3380d4944735d Mon Sep 17 00:00:00 2001
From: Fabien Villepinte <fabien.villepinte@gmail.com>
Date: Fri, 3 May 2024 15:50:55 +0200
Subject: [PATCH] Allow installation of PHPUnit 9 in order to test with PHP 8.3
---
.github/workflows/tests.yml | 1 +
composer.json | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 68b483587..de0cfff6f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -23,6 +23,7 @@ jobs:
- '8.0'
- '8.1'
- '8.2'
+ - '8.3'
name: PHP ${{ matrix.php }}
diff --git a/composer.json b/composer.json
index 180f341d8..c89b279e1 100644
--- a/composer.json
+++ b/composer.json
@@ -19,8 +19,8 @@
},
"require-dev": {
- "phpunit/php-file-iterator": "^1.4 || ^2.0",
- "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0"
+ "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0",
+ "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0"
},
"replace": {
|