Skip to content

Commit 2c3ba3b

Browse files
authored
Merge pull request #7593 from BacLuc/fix-phpunit-deprecations
Fix some phpunit deprecations
2 parents fc93e47 + dd16c53 commit 2c3ba3b

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

api/phpunit.nodocker.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
colors="true"
88
bootstrap="tests/bootstrap.php"
99
cacheDirectory=".phpunit.cache"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
displayDetailsOnTestsThatTriggerDeprecations="true"
12+
displayDetailsOnTestsThatTriggerErrors="true"
13+
displayDetailsOnTestsThatTriggerNotices="true"
14+
displayDetailsOnTestsThatTriggerWarnings="true"
1015
>
1116
<php>
1217
<ini name="display_errors" value="1"/>

api/phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
colors="true"
88
bootstrap="tests/bootstrap.php"
99
cacheDirectory=".phpunit.cache"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
displayDetailsOnTestsThatTriggerDeprecations="true"
12+
displayDetailsOnTestsThatTriggerErrors="true"
13+
displayDetailsOnTestsThatTriggerNotices="true"
14+
displayDetailsOnTestsThatTriggerWarnings="true"
1015
>
1116
<php>
1217
<ini name="display_errors" value="1"/>

api/tests/State/ContentNodes/SingleTextPersistProcessorTest.php

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,33 @@
99
use App\Entity\ContentNode\SingleText;
1010
use App\InputFilter\CleanHTMLFilter;
1111
use App\State\ContentNode\SingleTextPersistProcessor;
12-
use PHPUnit\Framework\MockObject\MockObject;
12+
use PHPUnit\Framework\MockObject\Exception;
1313
use PHPUnit\Framework\TestCase;
1414

15+
use function PHPUnit\Framework\assertThat;
16+
use function PHPUnit\Framework\equalTo;
17+
use function PHPUnit\Framework\logicalNot;
18+
1519
/**
1620
* @internal
1721
*/
1822
class SingleTextPersistProcessorTest extends TestCase {
1923
private SingleTextPersistProcessor $processor;
20-
21-
private CleanHTMLFilter|MockObject $cleanHTMLFilter;
2224
private ColumnLayout $root;
2325
private SingleText $contentNode;
2426

27+
/**
28+
* @throws Exception
29+
*/
2530
protected function setUp(): void {
2631
$decoratedProcessor = $this->createMock(ProcessorInterface::class);
27-
$this->cleanHTMLFilter = $this->createMock(CleanHTMLFilter::class);
28-
$this->cleanHTMLFilter->method('applyTo')->will(
29-
$this->returnCallback(
30-
function ($object, $property) {
31-
$object[$property] = '***sanitizedHTML***';
32+
$cleanHTMLFilter = $this->createMock(CleanHTMLFilter::class);
33+
$cleanHTMLFilter->method('applyTo')->willReturnCallback(
34+
function ($object, $property) {
35+
$object[$property] = '***sanitizedHTML***';
3236

33-
return $object;
34-
}
35-
)
37+
return $object;
38+
}
3639
);
3740

3841
$this->contentNode = new SingleText();
@@ -44,33 +47,24 @@ function ($object, $property) {
4447
$this->contentNode->parent = new SingleText();
4548
$this->contentNode->parent->root = $this->root;
4649

47-
$this->processor = new SingleTextPersistProcessor($decoratedProcessor, $this->cleanHTMLFilter);
50+
$this->processor = new SingleTextPersistProcessor($decoratedProcessor, $cleanHTMLFilter);
4851
}
4952

5053
public function testSetsRootFromParentOnCreate() {
51-
// when
52-
/** @var SingleText $data */
5354
$data = $this->processor->onBefore($this->contentNode, new Post());
5455

55-
// then
56-
$this->assertEquals($this->root, $data->root);
56+
assertThat($this->root, equalTo($data->root));
5757
}
5858

5959
public function testDoesNotSetRootFromParentOnUpdate() {
60-
// when
61-
/** @var SingleText $data */
6260
$data = $this->processor->onBefore($this->contentNode, new Patch());
6361

64-
// then
65-
$this->assertNotEquals($this->root, $data->root);
62+
assertThat($this->root, logicalNot(equalTo($data->root)));
6663
}
6764

68-
public function testSantizeData() {
69-
// when
70-
/** @var SingleText $data */
65+
public function testSanitizeData() {
7166
$data = $this->processor->onBefore($this->contentNode, new Post());
7267

73-
// then
74-
$this->assertEquals('***sanitizedHTML***', $data->data['html']);
68+
assertThat('***sanitizedHTML***', equalTo($data->data['html']));
7569
}
7670
}

api/tests/State/ResendActivationProcessorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class ResendActivationProcessorTest extends TestCase {
3131
private MockObject|UserRepository $userRepository;
3232
private MailService|MockObject $mailService;
3333

34+
private ResendActivationProcessor $processor;
35+
3436
/**
3537
* @throws Exception
3638
*/

0 commit comments

Comments
 (0)