Skip to content

Commit 8ed42c2

Browse files
PHPUnit 10
1 parent 1bf266e commit 8ed42c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+240
-209
lines changed

.github/workflows/run-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
- name: Run tests
8181
run: |
8282
vendor/bin/phpstan analyze src/ tests/ --level=1 --memory-limit=1G
83-
vendor/bin/phpunit -c phpunit.xml --exclude-group skip_for_solr_${{ matrix.mode }} -v --coverage-clover build/logs/clover.xml
83+
vendor/bin/phpunit -c phpunit.xml --exclude-group skip_for_solr_${{ matrix.mode }} --coverage-clover build/logs/clover.xml
8484
8585
- name: Execute examples
8686
run: |

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/lucene-solr
44
/vendor
55
.idea
6-
/.phpunit.result.cache
6+
/.phpunit.cache
77
/.php_cs.cache
88
/.phpcs-cache
99
.DS_Store

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"phpstan/phpstan": "^1.0",
3232
"phpstan/phpstan-deprecation-rules": "^1.0",
3333
"phpstan/phpstan-phpunit": "^1.0",
34-
"phpunit/phpunit": "^9.6",
34+
"phpunit/phpunit": "^10.5",
3535
"rawr/phpunit-data-provider": "^3.3",
3636
"roave/security-advisories": "dev-master",
3737
"symfony/event-dispatcher": "^5.0 || ^6.0 || ^7.0"

phpunit.xml

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
55
backupGlobals="false"
6-
backupStaticAttributes="false"
6+
backupStaticProperties="false"
7+
cacheDirectory=".phpunit.cache"
78
colors="true"
8-
convertDeprecationsToExceptions="true"
9+
displayDetailsOnTestsThatTriggerDeprecations="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
displayDetailsOnTestsThatTriggerErrors="true"
12+
displayDetailsOnTestsThatTriggerNotices="true"
13+
displayDetailsOnTestsThatTriggerWarnings="true"
914
>
1015
<coverage>
11-
<include>
12-
<directory suffix=".php">src</directory>
13-
</include>
1416
<report>
1517
<clover outputFile="build/logs/clover.xml"/>
1618
<html outputDirectory="build/coverage" lowUpperBound="35" highLowerBound="70"/>
@@ -21,6 +23,11 @@
2123
<directory suffix="Test.php">tests</directory>
2224
</testsuite>
2325
</testsuites>
26+
<source>
27+
<include>
28+
<directory suffix=".php">src</directory>
29+
</include>
30+
</source>
2431
<logging>
2532
<junit outputFile="build/logs/junit.xml"/>
2633
</logging>

tests/Component/Analytics/Facet/ObjectTraitTest.php

+19-23
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,24 @@
1818
*/
1919
class ObjectTraitTest extends TestCase
2020
{
21+
/**
22+
* @var object
23+
*/
24+
protected $objectTrait;
25+
26+
public function setUp(): void
27+
{
28+
$this->objectTrait = new class() {
29+
use ObjectTrait;
30+
};
31+
}
32+
2133
/**
2234
* @throws \PHPUnit\Framework\ExpectationFailedException
2335
*/
2436
public function testNullReturn(): void
2537
{
26-
$mock = $this->getMockForTrait(ObjectTrait::class);
27-
28-
$this->assertNull($mock->ensureObject(AbstractFacet::class, null));
38+
$this->assertNull($this->objectTrait->ensureObject(AbstractFacet::class, null));
2939
}
3040

3141
/**
@@ -34,21 +44,16 @@ public function testNullReturn(): void
3444
*/
3545
public function testReturnVariable(): void
3646
{
37-
$mock = $this->getMockForTrait(ObjectTrait::class);
38-
39-
$this->assertInstanceOf(PivotFacet::class, $mock->ensureObject(AbstractFacet::class, new PivotFacet()));
47+
$this->assertInstanceOf(PivotFacet::class, $this->objectTrait->ensureObject(AbstractFacet::class, new PivotFacet()));
4048
}
4149

4250
/**
4351
* Test non existing class.
4452
*/
4553
public function testNonExistingClass(): void
4654
{
47-
$mock = $this->getMockForTrait(ObjectTrait::class);
48-
4955
$this->expectException(InvalidArgumentException::class);
50-
51-
$mock->ensureObject('Foo\Bar', new PivotFacet());
56+
$this->objectTrait->ensureObject('Foo\Bar', new PivotFacet());
5257
}
5358

5459
/**
@@ -57,9 +62,7 @@ public function testNonExistingClass(): void
5762
*/
5863
public function testFromArray(): void
5964
{
60-
$mock = $this->getMockForTrait(ObjectTrait::class);
61-
62-
$this->assertInstanceOf(Sort::class, $mock->ensureObject(Sort::class, []));
65+
$this->assertInstanceOf(Sort::class, $this->objectTrait->ensureObject(Sort::class, []));
6366
}
6467

6568
/**
@@ -68,31 +71,24 @@ public function testFromArray(): void
6871
*/
6972
public function testFromClassMap(): void
7073
{
71-
$mock = $this->getMockForTrait(ObjectTrait::class);
72-
73-
$this->assertInstanceOf(PivotFacet::class, $mock->ensureObject(AbstractFacet::class, ['type' => AbstractFacet::TYPE_PIVOT]));
74+
$this->assertInstanceOf(PivotFacet::class, $this->objectTrait->ensureObject(AbstractFacet::class, ['type' => AbstractFacet::TYPE_PIVOT]));
7475
}
7576

7677
/**
7778
* Test invalid variable type.
7879
*/
7980
public function testInvalidVariableType(): void
8081
{
81-
$mock = $this->getMockForTrait(ObjectTrait::class);
82-
8382
$this->expectException(InvalidArgumentException::class);
84-
85-
$mock->ensureObject(PivotFacet::class, true);
83+
$this->objectTrait->ensureObject(PivotFacet::class, true);
8684
}
8785

8886
/**
8987
* Test invalid mapping type.
9088
*/
9189
public function testInvalidMappingType(): void
9290
{
93-
$mock = $this->getMockForTrait(ObjectTrait::class);
94-
9591
$this->expectException(InvalidArgumentException::class);
96-
$mock->ensureObject(AbstractFacet::class, ['type' => 'foo']);
92+
$this->objectTrait->ensureObject(AbstractFacet::class, ['type' => 'foo']);
9793
}
9894
}

tests/Component/FacetSetTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public function testCreateFacetWithInvalidType()
427427
$this->facetSet->createFacet('invalidtype');
428428
}
429429

430-
public function createFacetAddProvider()
430+
public static function createFacetAddProvider(): array
431431
{
432432
return [
433433
[true],

tests/Component/ResponseParser/AnalyticsTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public function testParseData(): void
102102
$parser = new ResponseParser();
103103
$result = $parser->parse(null, $component, $data);
104104

105-
$this->assertCount(\count($result->getResults()), $result);
106-
$this->assertCount(\count($result->getIterator()), $result);
105+
$this->assertSameSize($result->getResults(), $result);
106+
$this->assertSameSize($result->getIterator(), $result);
107107
$this->assertArrayHasKey('geo_sales', $result->getGroupings());
108108

109109
$this->assertInstanceOf(AnalyticsResult::class, $result);
@@ -123,8 +123,8 @@ public function testParseData(): void
123123
$this->assertSame('country', $facets[0]->getPivot());
124124
$this->assertSame('usa', $facets[0]->getValue());
125125

126-
$this->assertCount(\count($facets[0]->getResults()), $facets[0]);
127-
$this->assertCount(\count($facets[0]->getIterator()), $facets[0]);
126+
$this->assertSameSize($facets[0]->getResults(), $facets[0]);
127+
$this->assertSameSize($facets[0]->getIterator(), $facets[0]);
128128

129129
$this->assertCount(1, $facets[0]->getChildren());
130130
$this->assertCount(1, $facets[0]->getChildren()[0]->getChildren());

tests/Component/ResponseParser/SpellcheckTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function testParseExtended($data)
5656
);
5757
}
5858

59-
public function providerParseExtended()
59+
public static function providerParseExtended(): array
6060
{
6161
return [
6262
'solr4' => [
@@ -237,7 +237,7 @@ public function testParse($data)
237237
$this->assertEquals('dell ultrasharp new', $collations[1]->getQuery());
238238
}
239239

240-
public function providerParse()
240+
public static function providerParse(): array
241241
{
242242
return [
243243
'solr4' => [
@@ -333,7 +333,7 @@ public function testParseSingleCollation($data)
333333
$this->assertEquals(['word' => 'ultrasharpy', 'freq' => 1], $words[1]);
334334
}
335335

336-
public function providerParseSingleCollation()
336+
public static function providerParseSingleCollation(): array
337337
{
338338
return [
339339
'solr4' => [

tests/Component/ResponseParser/SuggesterTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function testParse($data)
5151
$this->assertEquals($allExpected, $result->getAll());
5252
}
5353

54-
public function providerParse()
54+
public static function providerParse(): array
5555
{
5656
return [
5757
0 => [

tests/Component/ResponseParser/TermVectorTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public function testParseWtPhps(Result $expectedResult)
233233
$this->assertEquals($expectedResult, $result);
234234
}
235235

236-
public function expectedResultProvider(): array
236+
public static function expectedResultProvider(): array
237237
{
238238
$result = new Result(
239239
[
@@ -358,7 +358,7 @@ public function testParseAmbiguousKeysWtPhps(Result $expectedResult)
358358
$this->assertEquals($expectedResult, $result);
359359
}
360360

361-
public function expectedResultAmbiguousKeysProvider(): array
361+
public static function expectedResultAmbiguousKeysProvider(): array
362362
{
363363
$result = new Result(
364364
[
@@ -457,7 +457,7 @@ public function testParseDoubleKeysWtPhps(Result $expectedResult)
457457
$this->assertEquals($expectedResult, $result);
458458
}
459459

460-
public function expectedResultDoubleKeysProvider(): array
460+
public static function expectedResultDoubleKeysProvider(): array
461461
{
462462
$result = new Result(
463463
[
@@ -540,7 +540,7 @@ public function testParseNoDocumentsWtPhps(Result $expectedResult)
540540
$this->assertEquals($expectedResult, $result);
541541
}
542542

543-
public function expectedResultNoDocumentsProvider(): array
543+
public static function expectedResultNoDocumentsProvider(): array
544544
{
545545
$result = new Result(
546546
[],

tests/Component/Result/Debug/DebugTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ public function testIterator()
9999

100100
public function testCount()
101101
{
102-
$this->assertCount(count($this->explain), $this->result);
102+
$this->assertSameSize($this->explain, $this->result);
103103
}
104104
}

tests/Component/Result/Debug/DocumentSetTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public function testIterator()
5959

6060
public function testCount()
6161
{
62-
$this->assertCount(count($this->docs), $this->result);
62+
$this->assertSameSize($this->docs, $this->result);
6363
}
6464
}

tests/Component/Result/Debug/DocumentTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function testIterator()
6161

6262
public function testCount()
6363
{
64-
$this->assertCount(count($this->details), $this->result);
64+
$this->assertSameSize($this->details, $this->result);
6565
}
6666

6767
public function testToString()

tests/Component/Result/Debug/TimingPhaseTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ public function testIterator()
6969

7070
public function testCount()
7171
{
72-
$this->assertCount(count($this->timings), $this->result);
72+
$this->assertSameSize($this->timings, $this->result);
7373
}
7474
}

tests/Component/Result/Debug/TimingTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ public function testIterator()
7070

7171
public function testCount()
7272
{
73-
$this->assertCount(count($this->phases), $this->result);
73+
$this->assertSameSize($this->phases, $this->result);
7474
}
7575
}

tests/Component/Result/MoreLikeThis/MoreLikeThisTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ public function testIterator()
109109

110110
public function testCount()
111111
{
112-
$this->assertCount(count($this->results), $this->mlt);
112+
$this->assertSameSize($this->results, $this->mlt);
113113
}
114114
}

tests/Component/Result/MoreLikeThis/ResultTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public function testIterator()
5555

5656
public function testCount()
5757
{
58-
$this->assertCount(count($this->docs), $this->mltResult);
58+
$this->assertSameSize($this->docs, $this->mltResult);
5959
}
6060
}

tests/Component/Result/Spellcheck/CollationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public function testIterator()
5757

5858
public function testCount()
5959
{
60-
$this->assertCount(count($this->corrections), $this->result);
60+
$this->assertSameSize($this->corrections, $this->result);
6161
}
6262
}

tests/Component/Result/Spellcheck/SpellcheckTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,6 @@ public function testIterator()
8989

9090
public function testCount()
9191
{
92-
$this->assertCount(count($this->suggestions), $this->result);
92+
$this->assertSameSize($this->suggestions, $this->result);
9393
}
9494
}

tests/Component/Result/Suggester/ResultTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public function testIterator()
5757

5858
public function testCount()
5959
{
60-
$this->assertCount(count($this->docs), $this->result);
60+
$this->assertSameSize($this->docs, $this->result);
6161
}
6262
}

tests/Core/Client/Adapter/CurlTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Solarium\Exception\HttpException;
1212
use Solarium\Exception\InvalidArgumentException;
1313

14+
/**
15+
* @requires extension curl
16+
*/
1417
class CurlTest extends TestCase
1518
{
1619
use TimeoutAwareTestTrait;
@@ -24,10 +27,6 @@ class CurlTest extends TestCase
2427

2528
public function setUp(): void
2629
{
27-
if (!\function_exists('curl_init')) {
28-
$this->markTestSkipped('cURL not available, skipping cURL adapter tests.');
29-
}
30-
3130
$this->adapter = new Curl();
3231
}
3332

@@ -131,7 +130,7 @@ public function testCreateHandleForRequestMethod(string $method)
131130
curl_close($handle);
132131
}
133132

134-
public function methodProvider(): array
133+
public static function methodProvider(): array
135134
{
136135
return [
137136
[Request::METHOD_GET],

0 commit comments

Comments
 (0)