Skip to content

Commit 8be857f

Browse files
authored
Merge pull request dokuwiki#4360 from dokuwiki/php84
PHP 8.4 fixes
2 parents b327c21 + 36784b8 commit 8be857f

File tree

113 files changed

+930
-1187
lines changed

Some content is hidden

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

113 files changed

+930
-1187
lines changed

_test/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require-dev": {
1313
"rector/rector": "^0.19",
1414
"squizlabs/php_codesniffer": "^3.7",
15-
"phpunit/phpunit": "^8.5"
15+
"phpunit/phpunit": "^9.0"
1616
},
1717
"scripts": {
1818
"test": [

_test/composer.lock

Lines changed: 598 additions & 278 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

_test/core/DokuWikiTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
use dokuwiki\Extension\PluginController;
44
use dokuwiki\Extension\Event;
55
use dokuwiki\Extension\EventHandler;
6+
use dokuwiki\Logger;
7+
68
/**
79
* Helper class to provide basic functionality for tests
810
*
@@ -266,4 +268,17 @@ protected static function setInaccessibleProperty($obj, $prop, $value) {
266268
$property->setAccessible(true);
267269
$property->setValue($obj, $value);
268270
}
271+
272+
/**
273+
* Expect the next log message to contain $message
274+
*
275+
* @param string $facility
276+
* @param string $message
277+
* @return void
278+
*/
279+
protected function expectLogMessage(string $message, string $facility = Logger::LOG_ERROR): void
280+
{
281+
$logger = Logger::getInstance($facility);
282+
$logger->expect($message);
283+
}
269284
}

_test/phpunit.xml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit
3-
bootstrap="bootstrap.php"
4-
convertNoticesToExceptions="false"
5-
colors="true"
6-
stderr="true"
7-
backupGlobals="true"
8-
>
9-
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="bootstrap.php"
4+
convertNoticesToExceptions="false"
5+
colors="true"
6+
stderr="true"
7+
backupGlobals="true"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
9+
<coverage includeUncoveredFiles="false">
10+
<include>
11+
<directory suffix=".php">../</directory>
12+
</include>
13+
<exclude>
14+
<directory suffix=".php">../_cs/</directory>
15+
<directory suffix=".php">../_test/</directory>
16+
<directory suffix=".php">../lib/plugins/*/_test/</directory>
17+
<directory suffix=".php">../lib/tpl/*/_test/</directory>
18+
</exclude>
19+
</coverage>
1020
<testsuites>
1121
<testsuite name="DokuWiki Tests">
1222
<directory suffix=".test.php">tests/</directory>
@@ -21,23 +31,9 @@
2131
<directory suffix="Test.php">../lib/tpl/*/_test/</directory>
2232
</testsuite>
2333
</testsuites>
24-
2534
<groups>
2635
<exclude>
2736
<group>flaky</group>
2837
</exclude>
2938
</groups>
30-
31-
<filter>
32-
<whitelist addUncoveredFilesFromWhitelist="false">
33-
<directory suffix=".php">../</directory>
34-
<exclude>
35-
<directory suffix=".php">../_cs/</directory>
36-
<directory suffix=".php">../_test/</directory>
37-
<directory suffix=".php">../lib/plugins/*/_test/</directory>
38-
<directory suffix=".php">../lib/tpl/*/_test/</directory>
39-
</exclude>
40-
</whitelist>
41-
</filter>
42-
4339
</phpunit>

_test/tests/Remote/ApiCoreTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ public function testSavePage()
674674
'text' => '',
675675
];
676676
$this->assertTrue($this->remote->call('core.savePage', $params));
677-
$this->assertFileNotExists(wikiFN($id));
677+
$this->assertFileDoesNotExist(wikiFN($id));
678678

679679
// remove non existing page (reusing above params)
680680
$e = null;
@@ -901,7 +901,7 @@ public function testDeleteMedia()
901901

902902
// deletion should work now
903903
$this->assertTrue($this->remote->call('core.deleteMedia', ['media' => $id]));
904-
$this->assertFileNotExists($file);
904+
$this->assertFileDoesNotExist($file);
905905

906906
clearstatcache(false, $file);
907907

_test/tests/inc/JWTTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function testCreation()
1212
{
1313
// no token file yet
1414
$file = JWT::getStorageFile('test');
15-
$this->assertFileNotExists($file);
15+
$this->assertFileDoesNotExist($file);
1616

1717
// initialize a new token
1818
$jwt = JWT::fromUser('test');

_test/tests/inc/common_saveWikiText.test.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ private function checkChangeLogAfterExternalEdit(
7373
$expectedCurrentEntry += $currentRevInfo;
7474
if ($expectedRevs > 0) {
7575
$this->assertEquals($expectedCurrentEntry, $currentRevInfo);
76-
76+
7777
}
7878
// attic
7979
$attic = wikiFN($currentRevInfo['id'], $currentRevInfo['date']);
80-
$this->assertFileNotExists($attic, 'page does not yet exist in attic');
80+
$this->assertFileDoesNotExist($attic, 'page does not yet exist in attic');
8181
}
8282

8383

@@ -99,7 +99,7 @@ function test_savesequence1() {
9999

100100
$page = 'page';
101101
$file = wikiFN($page);
102-
$this->assertFileNotExists($file);
102+
$this->assertFileDoesNotExist($file);
103103

104104
// 1.1 create a page
105105
saveWikiText($page, 'teststring', '1st save', false);
@@ -190,7 +190,7 @@ function test_savesequence1() {
190190
// 1.6 delete
191191
saveWikiText($page, '', '6th save', false);
192192
clearstatcache(false, $file);
193-
$this->assertFileNotExists($file);
193+
$this->assertFileDoesNotExist($file);
194194
$expectedRevs = 5;
195195
$expect = array(
196196
//'date' => $lastmod, // ignore from lastRev assertion, but confirm attic file existence
@@ -283,7 +283,7 @@ function test_savesequence2() {
283283

284284
$page = 'page2';
285285
$file = wikiFN($page);
286-
$this->assertFileNotExists($file);
286+
$this->assertFileDoesNotExist($file);
287287

288288
// 2.1 create a page
289289
saveWikiText($page, 'teststring', 'Test 2, 1st save', false);
@@ -306,7 +306,7 @@ function test_savesequence2() {
306306
// 2.2 delete
307307
saveWikiText($page, '', 'Test 2, 2nd save', false);
308308
clearstatcache(false, $file);
309-
$this->assertFileNotExists($file);
309+
$this->assertFileDoesNotExist($file);
310310
$expectedRevs = 2;
311311
$expect = array(
312312
//'date' => $lastmod, // ignore from lastRev assertion, but confirm attic file existence
@@ -406,7 +406,7 @@ function test_savesequence3() {
406406
$file = wikiFN($page);
407407

408408
// 3.1 externally create a page
409-
$this->assertFileNotExists($file);
409+
$this->assertFileDoesNotExist($file);
410410
file_put_contents($file, 'teststring');
411411
clearstatcache(false, $file);
412412
$lastmod = filemtime($file);
@@ -488,7 +488,7 @@ function test_savesequence4() {
488488
$file = wikiFN($page);
489489

490490
// 4.1 externally create a page
491-
$this->assertFileNotExists($file);
491+
$this->assertFileDoesNotExist($file);
492492
file_put_contents($file, 'teststring');
493493
clearstatcache(false, $file);
494494
$lastmod = filemtime($file);
@@ -527,7 +527,7 @@ function test_savesequence4() {
527527

528528
// 4.3 externally edit as a result of a file which has older timestamp than last revision
529529
unlink($file);
530-
file_put_contents($file, 'teststring fake 1 hout past');
530+
file_put_contents($file, 'teststring fake 1 hour past');
531531
touch($file, filemtime($file) -3600); // change file modification time to 1 hour past
532532
clearstatcache();
533533
$newmod = filemtime($file);
@@ -540,6 +540,7 @@ function test_savesequence4() {
540540
'sizechange' => 16,
541541
);
542542

543+
$this->expectLogMessage('current file modification time is older than last');
543544
$pagelog = new PageChangeLog($page);
544545
$this->checkChangeLogAfterExternalEdit($pagelog, $expectedRevs, $expect, $expectExternal);
545546
}
@@ -558,7 +559,7 @@ function test_savesequence4() {
558559
function test_savesequence5() {
559560
$page = 'page5';
560561
$file = wikiFN($page);
561-
$this->assertFileNotExists($file);
562+
$this->assertFileDoesNotExist($file);
562563

563564
// 5.1 create a page
564565
saveWikiText($page, 'teststring', 'Test 5, 1st save', false);
@@ -618,7 +619,7 @@ function test_savesequence5() {
618619
// 5.4 delete
619620
saveWikiText($page, '', 'Test 5 3rd save', false);
620621
clearstatcache(false, $file);
621-
$this->assertFileNotExists($file);
622+
$this->assertFileDoesNotExist($file);
622623
$expectedRevs = 4;
623624
$expect = array(
624625
//'date' => $lastmod, // ignore from lastRev assertion, but confirm attic file existence
@@ -633,7 +634,7 @@ function test_savesequence5() {
633634
$this->waitForTick(); // wait for new revision ID
634635

635636
// 5.5 create a page, second time
636-
$this->assertFileNotExists($file);
637+
$this->assertFileDoesNotExist($file);
637638
saveWikiText($page, 'teststring revived', 'Test 5, 4th save', false);
638639
$this->assertFileExists($file);
639640
$lastmod = filemtime($file);
@@ -652,7 +653,7 @@ function test_savesequence5() {
652653

653654
// 5.6 externally delete
654655
unlink($file);
655-
$this->assertFileNotExists($file);
656+
$this->assertFileDoesNotExist($file);
656657
$expectedRevs = 5;
657658
$expectExternal = array(
658659
//'date' => $lastmod,
@@ -667,7 +668,7 @@ function test_savesequence5() {
667668
$this->waitForTick(true); // wait for new revision ID
668669

669670
// 5.7 create a page, third time
670-
$this->assertFileNotExists($file);
671+
$this->assertFileDoesNotExist($file);
671672
saveWikiText($page, 'teststring revived 2', 'Test 5, 5th save', false);
672673
clearstatcache(false, $file);
673674
$this->assertFileExists($file);

_test/tests/inc/html_hilight.test.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,71 @@ class html_hilight_test extends DokuWikiTest {
44

55
function testHighlightOneWord() {
66
$html = 'Foo bar Foo';
7-
$this->assertRegExp(
7+
$this->assertMatchesRegularExpression(
88
'/Foo <span.*>bar<\/span> Foo/',
99
html_hilight($html,'bar')
1010
);
1111
}
1212

1313
function testHighlightTwoWords() {
1414
$html = 'Foo bar Foo php Foo';
15-
$this->assertRegExp(
15+
$this->assertMatchesRegularExpression(
1616
'/Foo <span.*>bar<\/span> Foo <span.*>php<\/span> Foo/',
1717
html_hilight($html,array('bar','php'))
1818
);
1919
}
2020

2121
function testHighlightTwoWordsHtml() {
2222
$html = 'Foo <b>bar</b> <i>Foo</i> php Foo';
23-
$this->assertRegExp(
23+
$this->assertMatchesRegularExpression(
2424
'/Foo <b><span.*>bar<\/span><\/b> <i>Foo<\/i> <span.*>php<\/span> Foo/',
2525
html_hilight($html,array('bar','php'))
2626
);
2727
}
2828

2929
function testNoMatchHtml() {
3030
$html = 'Foo <font>font</font> Bar';
31-
$this->assertRegExp(
31+
$this->assertMatchesRegularExpression(
3232
'/Foo <font><span.*>font<\/span><\/font> Bar/',
3333
html_hilight($html,'font')
3434
);
3535
}
3636

3737
function testWildcardRight() {
3838
$html = 'foo bar foobar barfoo foobarfoo foo';
39-
$this->assertRegExp(
39+
$this->assertMatchesRegularExpression(
4040
'/foo <span.*>bar<\/span> foobar <span.*>bar<\/span>foo foobarfoo foo/',
4141
html_hilight($html,'bar*')
4242
);
4343
}
4444

4545
function testWildcardLeft() {
4646
$html = 'foo bar foobar barfoo foobarfoo foo';
47-
$this->assertRegExp(
47+
$this->assertMatchesRegularExpression(
4848
'/foo <span.*>bar<\/span> foo<span.*>bar<\/span> barfoo foobarfoo foo/',
4949
html_hilight($html,'*bar')
5050
);
5151
}
5252

5353
function testWildcardBoth() {
5454
$html = 'foo bar foobar barfoo foobarfoo foo';
55-
$this->assertRegExp(
55+
$this->assertMatchesRegularExpression(
5656
'/foo <span.*>bar<\/span> foo<span.*>bar<\/span> <span.*>bar<\/span>foo foo<span.*>bar<\/span>foo foo/',
5757
html_hilight($html,'*bar*')
5858
);
5959
}
6060

6161
function testNoHighlight() {
6262
$html = 'Foo bar Foo';
63-
$this->assertRegExp(
63+
$this->assertMatchesRegularExpression(
6464
'/Foo bar Foo/',
6565
html_hilight($html,'php')
6666
);
6767
}
6868

6969
function testMatchAttribute() {
7070
$html = 'Foo <b class="x">bar</b> Foo';
71-
$this->assertRegExp(
71+
$this->assertMatchesRegularExpression(
7272
'/Foo <b class="x">bar<\/b> Foo/',
7373
html_hilight($html,'class="x"')
7474
);
@@ -84,47 +84,47 @@ function testMatchAttributeWord() {
8484

8585
function testRegexInjection() {
8686
$html = 'Foo bar Foo';
87-
$this->assertRegExp(
87+
$this->assertMatchesRegularExpression(
8888
'/Foo bar Foo/',
8989
html_hilight($html,'*')
9090
);
9191
}
9292

9393
function testRegexInjectionSlash() {
9494
$html = 'Foo bar Foo';
95-
$this->assertRegExp(
95+
$this->assertMatchesRegularExpression(
9696
'/Foo bar Foo/',
9797
html_hilight($html,'x/')
9898
);
9999
}
100100

101101
function testMB() {
102102
$html = 'foo ДокуВики bar';
103-
$this->assertRegExp(
103+
$this->assertMatchesRegularExpression(
104104
'/foo <span.*>ДокуВики<\/span> bar/',
105105
html_hilight($html,'ДокуВики')
106106
);
107107
}
108108

109109
function testMBright() {
110110
$html = 'foo ДокуВики bar';
111-
$this->assertRegExp(
111+
$this->assertMatchesRegularExpression(
112112
'/foo <span.*>Доку<\/span>Вики bar/',
113113
html_hilight($html,'Доку*')
114114
);
115115
}
116116

117117
function testMBleft() {
118118
$html = 'foo ДокуВики bar';
119-
$this->assertRegExp(
119+
$this->assertMatchesRegularExpression(
120120
'/foo Доку<span.*>Вики<\/span> bar/',
121121
html_hilight($html,'*Вики')
122122
);
123123
}
124124

125125
function testMBboth() {
126126
$html = 'foo ДокуВики bar';
127-
$this->assertRegExp(
127+
$this->assertMatchesRegularExpression(
128128
'/foo До<span.*>куВи<\/span>ки bar/',
129129
html_hilight($html,'*куВи*')
130130
);

0 commit comments

Comments
 (0)