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 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998
|
From: William Desportes <williamdes@wdes.fr>
Date: Sun, 13 Apr 2025 13:39:09 +0200
Subject: Update tests for newer PHPUnit versions
Origin: vendor
Forwarded: no
---
.../Test/Io/AbstractWinFileSystemTestCase.php | 34 +++++++++++---------
tests/Phing/Test/Io/FileParserFactoryTest.php | 3 +-
tests/Phing/Test/Io/FileSystemTest.php | 3 +-
tests/Phing/Test/Io/FileUtilsTest.php | 2 ++
tests/Phing/Test/Io/IniFileParserTest.php | 5 +--
tests/Phing/Test/Listener/DefaultLoggerTest.php | 7 ++++-
tests/Phing/Test/Listener/DisguiseLoggerTest.php | 7 +++++
tests/Phing/Test/Listener/MonologListenerTest.php | 1 +
tests/Phing/Test/Listener/SilentLoggerTest.php | 2 ++
.../Phing/Test/Listener/StatisticsListenerTest.php | 1 +
.../Phing/Test/Listener/TimestampedLoggerTest.php | 1 +
tests/Phing/Test/Parser/LocationTest.php | 6 ++--
tests/Phing/Test/TargetTest.php | 6 ++--
.../Phing/Test/Task/Ext/Svn/SvnRevertTaskTest.php | 1 +
.../Test/Task/Optional/WikiPublishTaskTest.php | 36 ++++++++++++++--------
tests/Phing/Test/Task/System/FileSizeTaskTest.php | 3 +-
tests/Phing/Test/Task/System/MkdirTaskTest.php | 14 +++++----
tests/Phing/Test/Task/System/PropertyTaskTest.php | 5 +--
tests/Phing/Test/Task/System/VersionTaskTest.php | 3 +-
tests/Phing/Test/Type/DescriptionTest.php | 5 +--
.../Type/Selector/PosixPermissionsSelectorTest.php | 9 ++++--
tests/Phing/Test/Util/CharacterTest.php | 5 +--
tests/Phing/Test/Util/SizeHelperTest.php | 12 +++++---
tests/Phing/Test/Util/StringHelperTest.php | 28 ++++++++++++-----
.../tasks/ext/phpunit/tests/provider_failTest.php | 3 +-
25 files changed, 137 insertions(+), 65 deletions(-)
diff --git a/tests/Phing/Test/Io/AbstractWinFileSystemTestCase.php b/tests/Phing/Test/Io/AbstractWinFileSystemTestCase.php
index e83f686..3898ecf 100644
--- a/tests/Phing/Test/Io/AbstractWinFileSystemTestCase.php
+++ b/tests/Phing/Test/Io/AbstractWinFileSystemTestCase.php
@@ -52,6 +52,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
/**
* @dataProvider normaliseDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('normaliseDataProvider')]
public function testNormalise(string $expected, string $path): void
{
$normalisedPath = $this->fs->normalize($path);
@@ -59,7 +60,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
$this->assertSame($expected, $normalisedPath);
}
- public function normaliseDataProvider(): array
+ public static function normaliseDataProvider(): array
{
return [
'alreadyNormal' => ['C:\\My Files\\file.txt', 'C:\\My Files\\file.txt'],
@@ -75,8 +76,9 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
}
/**
- * @dataProvider prefixLengthDataPRovider
+ * @dataProvider prefixLengthDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('prefixLengthDataProvider')]
public function testPrefixLength(int $expected, string $pathname): void
{
$length = $this->fs->prefixLength($pathname);
@@ -84,7 +86,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
$this->assertSame($expected, $length);
}
- public function prefixLengthDataProvider(): array
+ public static function prefixLengthDataProvider(): array
{
return [
'absoluteLocal' => [3, 'D:\\My Files\\file.txt'],
@@ -101,6 +103,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
/**
* @dataProvider resolveDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('resolveDataProvider')]
public function testResolve(string $expected, string $parent, string $child): void
{
$resolved = $this->fs->resolve($parent, $child);
@@ -108,7 +111,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
$this->assertSame($expected, $resolved);
}
- public function resolveDataProvider(): array
+ public static function resolveDataProvider(): array
{
return [
'emptyParent' => ['My Files\\file.txt', '', 'My Files\\file.txt'],
@@ -123,18 +126,19 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
/**
* @dataProvider resolveFileDataProvider
*/
- public function testResolveFile(string $expected, string $path, string $prefix): void
+ #[\PHPUnit\Framework\Attributes\DataProvider('resolveFileDataProvider')]
+ public function testResolveFile(string $expected, string $path, int $prefix): void
{
$file = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock();
- $file->expects($this->any())->method('getPath')->will($this->returnValue($path));
- $file->expects($this->any())->method('getPrefixLength')->will($this->returnValue($prefix));
+ $file->expects($this->any())->method('getPath')->willReturnMap([[$path]]);
+ $file->expects($this->any())->method('getPrefixLength')->willReturnMap([[$prefix]]);
$resolved = $this->fs->resolveFile($file);
$this->assertSame($expected, $resolved);
}
- public function resolveFileDataProvider(): array
+ public static function resolveFileDataProvider(): array
{
$cwd = getcwd();
$driveLetter = '';
@@ -163,8 +167,8 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
$this->expectExceptionMessage('Unresolvable path: file.txt');
$file = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock();
- $file->expects($this->any())->method('getPath')->will($this->returnValue('file.txt'));
- $file->expects($this->any())->method('getPrefixLength')->will($this->returnValue(5));
+ $file->expects($this->any())->method('getPath')->willReturnMap([['file.txt']]);
+ $file->expects($this->any())->method('getPrefixLength')->willReturnMap([[5]]);
$this->fs->resolveFile($file);
}
@@ -179,6 +183,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
/**
* @dataProvider fromURIPathDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('fromURIPathDataProvider')]
public function testFromURIPath(string $expected, string $path): void
{
$resultPath = $this->fs->fromURIPath($path);
@@ -186,7 +191,7 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
$this->assertSame($expected, $resultPath);
}
- public function fromURIPathDataProvider(): array
+ public static function fromURIPathDataProvider(): array
{
return [
'singleLetter' => ['f', 'f'],
@@ -200,18 +205,19 @@ abstract class AbstractWinFileSystemTestCase extends TestCase
/**
* @dataProvider isAbsoluteDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('isAbsoluteDataProvider')]
public function testIsAbsolute(bool $expected, string $path, int $prefix): void
{
$file = $this->getMockBuilder(File::class)->disableOriginalConstructor()->getMock();
- $file->expects($this->any())->method('getPath')->will($this->returnValue($path));
- $file->expects($this->any())->method('getPrefixLength')->will($this->returnValue($prefix));
+ $file->expects($this->any())->method('getPath')->willReturnMap([[$path]]);
+ $file->expects($this->any())->method('getPrefixLength')->willReturnMap([[$prefix]]);
$is = $this->fs->isAbsolute($file);
$this->assertSame($expected, $is);
}
- public function isAbsoluteDataProvider(): array
+ public static function isAbsoluteDataProvider(): array
{
return [
// Doesn't work for my current version of phpunit
diff --git a/tests/Phing/Test/Io/FileParserFactoryTest.php b/tests/Phing/Test/Io/FileParserFactoryTest.php
index d2a543c..9a46164 100644
--- a/tests/Phing/Test/Io/FileParserFactoryTest.php
+++ b/tests/Phing/Test/Io/FileParserFactoryTest.php
@@ -62,12 +62,13 @@ class FileParserFactoryTest extends TestCase
* @param mixed $parserName
* @param mixed $expectedType
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('parserTypeProvider')]
public function testCreateParser($parserName, $expectedType): void
{
$this->assertInstanceOf($expectedType, $this->objectToTest->createParser($parserName));
}
- public function parserTypeProvider(): array
+ public static function parserTypeProvider(): array
{
return [
['properties', IniFileParser::class],
diff --git a/tests/Phing/Test/Io/FileSystemTest.php b/tests/Phing/Test/Io/FileSystemTest.php
index 5f9cf84..ced70e7 100644
--- a/tests/Phing/Test/Io/FileSystemTest.php
+++ b/tests/Phing/Test/Io/FileSystemTest.php
@@ -68,6 +68,7 @@ class FileSystemTest extends TestCase
*
* @throws IOException
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('fileSystemMappingsDataProvider')]
public function testGetFileSystemReturnsCorrect($expectedFileSystemClass, $fsTypeKey): void
{
$this->resetFileSystem();
@@ -79,7 +80,7 @@ class FileSystemTest extends TestCase
$this->assertInstanceOf($expectedFileSystemClass, $system);
}
- public function fileSystemMappingsDataProvider(): array
+ public static function fileSystemMappingsDataProvider(): array
{
return [
[UnixFileSystem::class, 'UNIX'],
diff --git a/tests/Phing/Test/Io/FileUtilsTest.php b/tests/Phing/Test/Io/FileUtilsTest.php
index f99f649..f9c2758 100644
--- a/tests/Phing/Test/Io/FileUtilsTest.php
+++ b/tests/Phing/Test/Io/FileUtilsTest.php
@@ -51,6 +51,7 @@ class FileUtilsTest extends BuildFileTest
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function contentEquals(): void
{
$this->assertFalse($this->fu->contentEquals(new File(__FILE__), new File('does_not_exists')));
@@ -64,6 +65,7 @@ class FileUtilsTest extends BuildFileTest
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function copyFile(): void
{
$this->fu->copyFile(new File(__FILE__), new File('tmp/test.php'), $this->getProject());
diff --git a/tests/Phing/Test/Io/IniFileParserTest.php b/tests/Phing/Test/Io/IniFileParserTest.php
index dde968c..9aeec44 100644
--- a/tests/Phing/Test/Io/IniFileParserTest.php
+++ b/tests/Phing/Test/Io/IniFileParserTest.php
@@ -46,7 +46,7 @@ class IniFileParserTest extends TestCase
}
/**
- * @dataProvider provideIniFiles
+ * @dataProvider provideIniFilesProvider
* @covers \IniFileParser::inVal
* @covers \IniFileParser::parseFile
*
@@ -56,6 +56,7 @@ class IniFileParserTest extends TestCase
* @throws IOException
* @throws IOException
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('provideIniFilesProvider')]
public function testParseFile($data, $expected): void
{
$file = $this->root->url() . '/test';
@@ -77,7 +78,7 @@ class IniFileParserTest extends TestCase
$this->parser->parseFile($phingFile);
}
- public function provideIniFiles(): array
+ public static function provideIniFilesProvider(): array
{
return [
[
diff --git a/tests/Phing/Test/Listener/DefaultLoggerTest.php b/tests/Phing/Test/Listener/DefaultLoggerTest.php
index ed65a76..53903c5 100644
--- a/tests/Phing/Test/Listener/DefaultLoggerTest.php
+++ b/tests/Phing/Test/Listener/DefaultLoggerTest.php
@@ -38,6 +38,7 @@ class DefaultLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function throwableMessageOne(): void
{
$be = new BuildException('oops', new Location('build.xml', 1, 0));
@@ -47,6 +48,7 @@ class DefaultLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function throwableMessageTwo(): void
{
$be = new BuildException('oops', new Location('build.xml', 1, 0));
@@ -61,6 +63,7 @@ class DefaultLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function throwableMessageThree(): void
{
$be = new BuildException('oops', new Location('build.xml', 1, 0));
@@ -77,6 +80,7 @@ class DefaultLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinished(): void
{
$event = new BuildEvent(new Project());
@@ -101,13 +105,14 @@ class DefaultLoggerTest extends TestCase
*
* @param mixed $seconds
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('formatTimeProvider')]
public function testFormatTime($seconds, string $expectedText): void
{
$formattedText = DefaultLogger::formatTime($seconds);
$this->assertSame($formattedText, $expectedText);
}
- public function formatTimeProvider(): array
+ public static function formatTimeProvider(): array
{
return [
[0.0005, '0.0005 seconds'],
diff --git a/tests/Phing/Test/Listener/DisguiseLoggerTest.php b/tests/Phing/Test/Listener/DisguiseLoggerTest.php
index 80c23f9..b5f0eb1 100644
--- a/tests/Phing/Test/Listener/DisguiseLoggerTest.php
+++ b/tests/Phing/Test/Listener/DisguiseLoggerTest.php
@@ -22,6 +22,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function maskOutput()
{
$event = new BuildEvent(new Project());
@@ -32,6 +33,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildStarted()
{
$event = new BuildEvent(new Project());
@@ -42,6 +44,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinished()
{
$event = new BuildEvent(new Project());
@@ -52,6 +55,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function targetStarted()
{
$event = new BuildEvent(new Project());
@@ -62,6 +66,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function targetFinished()
{
$event = new BuildEvent(new Project());
@@ -72,6 +77,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function taskStarted()
{
$event = new BuildEvent(new Project());
@@ -82,6 +88,7 @@ class DisguiseLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function taskFinished()
{
$event = new BuildEvent(new Project());
diff --git a/tests/Phing/Test/Listener/MonologListenerTest.php b/tests/Phing/Test/Listener/MonologListenerTest.php
index 8b13a94..754607c 100644
--- a/tests/Phing/Test/Listener/MonologListenerTest.php
+++ b/tests/Phing/Test/Listener/MonologListenerTest.php
@@ -40,6 +40,7 @@ class MonologListenerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildStarted(): void
{
$listener = new MonologListener();
diff --git a/tests/Phing/Test/Listener/SilentLoggerTest.php b/tests/Phing/Test/Listener/SilentLoggerTest.php
index a52c841..47125c6 100644
--- a/tests/Phing/Test/Listener/SilentLoggerTest.php
+++ b/tests/Phing/Test/Listener/SilentLoggerTest.php
@@ -35,6 +35,7 @@ class SilentLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinished(): void
{
$event = new BuildEvent(new Project());
@@ -46,6 +47,7 @@ class SilentLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinishedException(): void
{
$event = new BuildEvent(new Project());
diff --git a/tests/Phing/Test/Listener/StatisticsListenerTest.php b/tests/Phing/Test/Listener/StatisticsListenerTest.php
index 1ad9f93..b46bd14 100644
--- a/tests/Phing/Test/Listener/StatisticsListenerTest.php
+++ b/tests/Phing/Test/Listener/StatisticsListenerTest.php
@@ -33,6 +33,7 @@ class StatisticsListenerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinished(): void
{
$event = new BuildEvent(new Project());
diff --git a/tests/Phing/Test/Listener/TimestampedLoggerTest.php b/tests/Phing/Test/Listener/TimestampedLoggerTest.php
index ea99f25..cf091e5 100644
--- a/tests/Phing/Test/Listener/TimestampedLoggerTest.php
+++ b/tests/Phing/Test/Listener/TimestampedLoggerTest.php
@@ -34,6 +34,7 @@ class TimestampedLoggerTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function buildFinished(): void
{
$event = new BuildEvent(new Project());
diff --git a/tests/Phing/Test/Parser/LocationTest.php b/tests/Phing/Test/Parser/LocationTest.php
index 227e821..131b5f0 100644
--- a/tests/Phing/Test/Parser/LocationTest.php
+++ b/tests/Phing/Test/Parser/LocationTest.php
@@ -30,19 +30,21 @@ class LocationTest extends TestCase
{
/**
* @test
- * @dataProvider locations
+ * @dataProvider locationsProvider
*
* @param mixed $fileName
* @param mixed $lineNumber
* @param mixed $columnNumber
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('locationsProvider')]
+ #[\PHPUnit\Framework\Attributes\Test]
public function location($fileName, $lineNumber, $columnNumber): void
{
$loc = new Location($fileName, $lineNumber, $columnNumber);
$this->assertSame(sprintf('%s:%s:%s', $fileName, $lineNumber, $columnNumber), (string) $loc);
}
- public function locations(): array
+ public static function locationsProvider(): array
{
return [
'normal' => ['test.php', 10, 20],
diff --git a/tests/Phing/Test/TargetTest.php b/tests/Phing/Test/TargetTest.php
index af4c51f..51c6cef 100644
--- a/tests/Phing/Test/TargetTest.php
+++ b/tests/Phing/Test/TargetTest.php
@@ -67,6 +67,7 @@ class TargetTest extends BuildFileTest
/**
* @dataProvider setDependsValidDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('setDependsValidDataProvider')]
public function testSetDependsValid(array $expectedDepends, string $depends): void
{
$this->target->setDepends($depends);
@@ -74,7 +75,7 @@ class TargetTest extends BuildFileTest
$this->assertEquals($expectedDepends, $this->target->getDependencies());
}
- public function setDependsValidDataProvider(): array
+ public static function setDependsValidDataProvider(): array
{
return [
[['target1'], 'target1'],
@@ -85,6 +86,7 @@ class TargetTest extends BuildFileTest
/**
* @dataProvider setDependsInvalidDataProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('setDependsInvalidDataProvider')]
public function testSetDependsInvalid(string $depends): void
{
$this->expectException(BuildException::class);
@@ -93,7 +95,7 @@ class TargetTest extends BuildFileTest
$this->target->setDepends($depends);
}
- public function setDependsInvalidDataProvider(): array
+ public static function setDependsInvalidDataProvider(): array
{
return [
[''],
diff --git a/tests/Phing/Test/Task/Ext/Svn/SvnRevertTaskTest.php b/tests/Phing/Test/Task/Ext/Svn/SvnRevertTaskTest.php
index 5bf7ebb..0d31bdc 100644
--- a/tests/Phing/Test/Task/Ext/Svn/SvnRevertTaskTest.php
+++ b/tests/Phing/Test/Task/Ext/Svn/SvnRevertTaskTest.php
@@ -38,6 +38,7 @@ class SvnRevertTaskTest extends AbstractSvnTaskTest
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function recursiveRevert(): void
{
$repository = PHING_TEST_BASE . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'svn';
diff --git a/tests/Phing/Test/Task/Optional/WikiPublishTaskTest.php b/tests/Phing/Test/Task/Optional/WikiPublishTaskTest.php
index 1cafb88..7cc4f6e 100644
--- a/tests/Phing/Test/Task/Optional/WikiPublishTaskTest.php
+++ b/tests/Phing/Test/Task/Optional/WikiPublishTaskTest.php
@@ -46,20 +46,30 @@ class WikiPublishTaskTest extends BuildFileTest
$task->setContent('some content');
$task->setMode('prepend');
- $task->expects($this->exactly(4))
+ $callParams = [
+ ['action=login', ['lgname' => 'testUser', 'lgpassword' => 'testPassword']],
+ ['action=login', ['lgname' => 'testUser', 'lgpassword' => 'testPassword', 'lgtoken' => 'testLgToken']],
+ ['action=tokens&type=edit'],
+ ['action=edit&token=testEditToken%2B%2F', ['minor' => '', 'title' => 'some page', 'prependtext' => 'some content']]
+ ];
+ $returnResults = [
+ ['login' => ['result' => 'NeedToken', 'token' => 'testLgToken']],
+ ['login' => ['result' => 'Success']],
+ ['tokens' => ['edittoken' => 'testEditToken+/']],
+ ['edit' => ['result' => 'Success']]
+ ];
+
+ $task->expects($this->exactly(count($callParams)))
->method('callApi')
- ->withConsecutive(
- ['action=login', ['lgname' => 'testUser', 'lgpassword' => 'testPassword']],
- ['action=login', ['lgname' => 'testUser', 'lgpassword' => 'testPassword', 'lgtoken' => 'testLgToken']],
- ['action=tokens&type=edit'],
- ['action=edit&token=testEditToken%2B%2F', ['minor' => '', 'title' => 'some page', 'prependtext' => 'some content']]
- )
- ->willReturnOnConsecutiveCalls(
- ['login' => ['result' => 'NeedToken', 'token' => 'testLgToken']],
- ['login' => ['result' => 'Success']],
- ['tokens' => ['edittoken' => 'testEditToken+/']],
- ['edit' => ['result' => 'Success']]
- )
+ ->willReturnCallback(function (string $action, array|null $args) use ($callParams, $returnResults): array {
+ $index = array_find_key($callParams, function (array $value) use ($action, $args): bool {
+ return $value[0] === $action && ($value[1] ?? null) === $args;
+ });
+ if (isset($callParams[$index])) {
+ $this->assertSame($callParams[$index][1] ?? null, $args);
+ return $returnResults[$index];
+ }
+ })
;
$task->main();
diff --git a/tests/Phing/Test/Task/System/FileSizeTaskTest.php b/tests/Phing/Test/Task/System/FileSizeTaskTest.php
index 8a0dfcc..4fea702 100644
--- a/tests/Phing/Test/Task/System/FileSizeTaskTest.php
+++ b/tests/Phing/Test/Task/System/FileSizeTaskTest.php
@@ -51,6 +51,7 @@ class FileSizeTaskTest extends BuildFileTest
* @param mixed $logInfo
* @param mixed $expectedSize
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('unitAttributeProvider')]
public function testUnitAttribute($dummySize, $filesizeUnit, $logVerbose, $logInfo, $expectedSize): void
{
$this->getProject()->setProperty('dummy.size', $dummySize);
@@ -61,7 +62,7 @@ class FileSizeTaskTest extends BuildFileTest
$this->assertPropertyEquals('filesize', $expectedSize);
}
- public function unitAttributeProvider(): array
+ public static function unitAttributeProvider(): array
{
return [
['1K', 'b', '1024B', '1024B', 1024],
diff --git a/tests/Phing/Test/Task/System/MkdirTaskTest.php b/tests/Phing/Test/Task/System/MkdirTaskTest.php
index f65eda4..0b48e8a 100644
--- a/tests/Phing/Test/Task/System/MkdirTaskTest.php
+++ b/tests/Phing/Test/Task/System/MkdirTaskTest.php
@@ -54,6 +54,7 @@ class MkdirTaskTest extends BuildFileTest
* @param mixed $umask
* @param mixed $expectedDirMode
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('umaskIsHonouredWhenNotUsingModeArgumentDataProvider')]
public function testUmaskIsHonouredWhenNotUsingModeArgument($umask, $expectedDirMode): void
{
if (0 !== $umask) {
@@ -65,7 +66,7 @@ class MkdirTaskTest extends BuildFileTest
$this->assertFileModeIs(PHING_TEST_BASE . '/etc/tasks/system/tmp/a', $expectedDirMode);
}
- public function umaskIsHonouredWhenNotUsingModeArgumentDataProvider(): array
+ public static function umaskIsHonouredWhenNotUsingModeArgumentDataProvider(): array
{
return [
[0000, 0777],
@@ -88,6 +89,7 @@ class MkdirTaskTest extends BuildFileTest
* @param mixed $expectedModeA
* @param mixed $expectedModeB
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('parentDirectoriesHaveDefaultPermissionsDataProvider')]
public function testParentDirectoriesHaveDefaultPermissions($umask, $expectedModeA, $expectedModeB): void
{
if (0 !== $umask) {
@@ -100,18 +102,18 @@ class MkdirTaskTest extends BuildFileTest
$this->assertFileModeIs(PHING_TEST_BASE . '/etc/tasks/system/tmp/a/b', $expectedModeB);
}
- public function parentDirectoriesHaveDefaultPermissionsDataProvider(): array
+ public static function parentDirectoriesHaveDefaultPermissionsDataProvider(): array
{
return [
[
'umask' => 0000,
- 'expectedPermissionsOfA' => 0777,
- 'expectedPermissionsOfB' => 0555,
+ 'expectedModeA' => 0777,
+ 'expectedModeB' => 0555,
],
[
'umask' => 0077,
- 'expectedPermissionsOfA' => 0700,
- 'expectedPermissionsOfB' => 0555,
+ 'expectedModeA' => 0700,
+ 'expectedModeB' => 0555,
],
];
}
diff --git a/tests/Phing/Test/Task/System/PropertyTaskTest.php b/tests/Phing/Test/Task/System/PropertyTaskTest.php
index e7c1aff..1c082ee 100644
--- a/tests/Phing/Test/Task/System/PropertyTaskTest.php
+++ b/tests/Phing/Test/Task/System/PropertyTaskTest.php
@@ -86,7 +86,7 @@ class PropertyTaskTest extends BuildFileTest
$this->assertEquals('World', $this->project->getProperty('filterchain.test'));
}
- public function circularDefinitionTargets(): array
+ public static function circularDefinitionTargetsProvider(): array
{
return [
['test3'],
@@ -96,10 +96,11 @@ class PropertyTaskTest extends BuildFileTest
}
/**
- * @dataProvider circularDefinitionTargets
+ * @dataProvider circularDefinitionTargetsProvider
*
* @param mixed $target
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('circularDefinitionTargetsProvider')]
public function testCircularDefinitionDetection($target): void
{
$this->expectException(BuildException::class);
diff --git a/tests/Phing/Test/Task/System/VersionTaskTest.php b/tests/Phing/Test/Task/System/VersionTaskTest.php
index dd6f882..05322aa 100644
--- a/tests/Phing/Test/Task/System/VersionTaskTest.php
+++ b/tests/Phing/Test/Task/System/VersionTaskTest.php
@@ -103,6 +103,7 @@ class VersionTaskTest extends BuildFileTest
* @throws ReflectionException
* @throws ReflectionException
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('versionProvider')]
public function testGetVersionMethod($releaseType, $version, $expectedVersion): void
{
$versionTask = new VersionTask();
@@ -116,7 +117,7 @@ class VersionTaskTest extends BuildFileTest
$this->assertSame($expectedVersion, $newVersion);
}
- public function versionProvider(): array
+ public static function versionProvider(): array
{
return [
[VersionTask::RELEASETYPE_MAJOR, null, '1.0.0'],
diff --git a/tests/Phing/Test/Type/DescriptionTest.php b/tests/Phing/Test/Type/DescriptionTest.php
index e1b6ef2..82157fa 100644
--- a/tests/Phing/Test/Type/DescriptionTest.php
+++ b/tests/Phing/Test/Type/DescriptionTest.php
@@ -28,18 +28,19 @@ class DescriptionTest extends BuildFileTest
/**
* Test that the aaddText method appends text to description w/o any spaces.
*
- * @dataProvider getFiles
+ * @dataProvider getFilesProvider
*
* @param mixed $fileName
* @param mixed $outcome
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('getFilesProvider')]
public function test($fileName, $outcome): void
{
$this->configureProject(PHING_TEST_BASE . "/etc/types/{$fileName}.xml");
$this->assertEquals($outcome, $this->getProject()->getDescription());
}
- public function getFiles(): array
+ public static function getFilesProvider(): array
{
return [
'Single' => ['description1', 'Test Project Description'],
diff --git a/tests/Phing/Test/Type/Selector/PosixPermissionsSelectorTest.php b/tests/Phing/Test/Type/Selector/PosixPermissionsSelectorTest.php
index ec80c89..3d7b6d5 100644
--- a/tests/Phing/Test/Type/Selector/PosixPermissionsSelectorTest.php
+++ b/tests/Phing/Test/Type/Selector/PosixPermissionsSelectorTest.php
@@ -54,6 +54,7 @@ class PosixPermissionsSelectorTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function argumentRequired(): void
{
$this->expectException(BuildException::class);
@@ -65,6 +66,7 @@ class PosixPermissionsSelectorTest extends TestCase
/**
* @test
*/
+ #[\PHPUnit\Framework\Attributes\Test]
public function isSelected(): void
{
$this->selector->setPermissions('rw-rw-r--');
@@ -85,6 +87,9 @@ class PosixPermissionsSelectorTest extends TestCase
*
* @param bool $throws
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('illegalArgumentProvider')]
+ #[\PHPUnit\Framework\Attributes\DataProvider('legalArgumentProvider')]
+ #[\PHPUnit\Framework\Attributes\Test]
public function argument(string $permission, $throws = false): void
{
if ($throws) {
@@ -96,7 +101,7 @@ class PosixPermissionsSelectorTest extends TestCase
$this->selector->setPermissions($permission);
}
- public function legalArgumentProvider(): array
+ public static function legalArgumentProvider(): array
{
return [
'legal octal string' => ['750'],
@@ -104,7 +109,7 @@ class PosixPermissionsSelectorTest extends TestCase
];
}
- public function illegalArgumentProvider(): array
+ public static function illegalArgumentProvider(): array
{
return [
['855', true],
diff --git a/tests/Phing/Test/Util/CharacterTest.php b/tests/Phing/Test/Util/CharacterTest.php
index 332408c..bd6c90a 100644
--- a/tests/Phing/Test/Util/CharacterTest.php
+++ b/tests/Phing/Test/Util/CharacterTest.php
@@ -46,16 +46,17 @@ class CharacterTest extends TestCase
}
/**
- * @dataProvider getChars
+ * @dataProvider getCharsProvider
*
* @param mixed $elem
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('getCharsProvider')]
public function testIsChar($elem, bool $expected): void
{
$this->assertSame($this->char::isLetter($elem), $expected);
}
- public function getChars(): array
+ public static function getCharsProvider(): array
{
return [
'more than 2' => ['as', false],
diff --git a/tests/Phing/Test/Util/SizeHelperTest.php b/tests/Phing/Test/Util/SizeHelperTest.php
index bb788d5..f01b758 100644
--- a/tests/Phing/Test/Util/SizeHelperTest.php
+++ b/tests/Phing/Test/Util/SizeHelperTest.php
@@ -34,13 +34,14 @@ class SizeHelperTest extends TestCase
*
* @param mixed $expectedBytes
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('fromHumanToBytesProvider')]
public function testFromHumanToBytes(string $humanSize, $expectedBytes): void
{
$bytes = SizeHelper::fromHumanToBytes($humanSize);
$this->assertSame($expectedBytes, $bytes);
}
- public function fromHumanToBytesProvider(): array
+ public static function fromHumanToBytesProvider(): array
{
return [
['1024', 1024.0],
@@ -89,6 +90,7 @@ class SizeHelperTest extends TestCase
/**
* @dataProvider invalidFromHumanToBytesProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidFromHumanToBytesProvider')]
public function testInvalidFromHumanToBytes(string $human, string $message): void
{
$this->expectException(BuildException::class);
@@ -96,7 +98,7 @@ class SizeHelperTest extends TestCase
SizeHelper::fromHumanToBytes($human);
}
- public function invalidFromHumanToBytesProvider(): array
+ public static function invalidFromHumanToBytesProvider(): array
{
return [
['', "Invalid size ''"],
@@ -115,13 +117,14 @@ class SizeHelperTest extends TestCase
/**
* @dataProvider fromBytesToProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('fromBytesToProvider')]
public function testFromBytesTo(int $bytes, string $unit, float $expected): void
{
$converted = SizeHelper::fromBytesTo($bytes, $unit);
$this->assertSame($expected, $converted);
}
- public function fromBytesToProvider(): array
+ public static function fromBytesToProvider(): array
{
return [
[1024, 'B', 1024],
@@ -164,6 +167,7 @@ class SizeHelperTest extends TestCase
/**
* @dataProvider invalidFromBytesToProvider
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('invalidFromBytesToProvider')]
public function testInvalidFromBytesTo(string $unit, string $message): void
{
$this->expectException(BuildException::class);
@@ -171,7 +175,7 @@ class SizeHelperTest extends TestCase
SizeHelper::fromBytesTo(1024, $unit);
}
- public function invalidFromBytesToProvider(): array
+ public static function invalidFromBytesToProvider(): array
{
return [
['', "Invalid unit ''"],
diff --git a/tests/Phing/Test/Util/StringHelperTest.php b/tests/Phing/Test/Util/StringHelperTest.php
index 31c85ba..dcb9b49 100644
--- a/tests/Phing/Test/Util/StringHelperTest.php
+++ b/tests/Phing/Test/Util/StringHelperTest.php
@@ -18,6 +18,7 @@ class StringHelperTest extends TestCase
* @param mixed $candidate
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('booleanValueProvider')]
public function testBooleanValue($candidate, $expected)
{
$result = StringHelper::booleanValue($candidate);
@@ -25,7 +26,7 @@ class StringHelperTest extends TestCase
$this->assertSame($expected, $result);
}
- public function booleanValueProvider(): array
+ public static function booleanValueProvider(): array
{
return [
// True values
@@ -81,6 +82,7 @@ class StringHelperTest extends TestCase
* @param string $candidate
* @param bool $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('isBooleanProvider')]
public function testIsBoolean($candidate, $expected)
{
$result = StringHelper::isBoolean($candidate);
@@ -88,7 +90,7 @@ class StringHelperTest extends TestCase
$this->assertSame($expected, $result);
}
- public function isBooleanProvider()
+ public static function isBooleanProvider(): array
{
return [
// Boolean values
@@ -146,13 +148,14 @@ class StringHelperTest extends TestCase
* @param mixed $haystack
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('startsWithProvider')]
public function testStartsWith($needle, $haystack, $expected)
{
$result = StringHelper::startsWith($needle, $haystack);
$this->assertSame($expected, $result);
}
- public function startsWithProvider()
+ public static function startsWithProvider(): array
{
return [
// True
@@ -180,13 +183,14 @@ class StringHelperTest extends TestCase
* @param mixed $haystack
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('endsWithProvider')]
public function testEndsWith($needle = 'o', $haystack = 'foo', $expected = true)
{
$result = StringHelper::endsWith($needle, $haystack);
$this->assertSame($expected, $result);
}
- public function endsWithProvider()
+ public static function endsWithProvider(): array
{
return [
// True
@@ -224,13 +228,14 @@ class StringHelperTest extends TestCase
* @param mixed $end
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('substringProvider')]
public function testSubstring($string, $start, $end, $expected)
{
$result = StringHelper::substring($string, $start, $end);
$this->assertSame($expected, $result);
}
- public function substringProvider()
+ public static function substringProvider(): array
{
return [
['FooBarBaz', 0, 0, 'F'],
@@ -255,14 +260,19 @@ class StringHelperTest extends TestCase
* @param mixed $end
* @param mixed $message
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('substringErrorProvider')]
public function testSubstringError($string, $start, $end, $message)
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage($message);
+
StringHelper::substring($string, $start, $end);
+
+ $this->assertSame($message, $userError);
+ restore_error_handler();
}
- public function substringErrorProvider()
+ public static function substringErrorProvider(): array
{
return [
['FooBarBaz', -1, 1, 'substring(), Startindex out of bounds must be 0<n<9'],
@@ -280,13 +290,14 @@ class StringHelperTest extends TestCase
* @param mixed $value
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('isSlotVarProvider')]
public function testIsSlotVar($value, $expected)
{
$result = StringHelper::isSlotVar($value);
$this->assertSame($expected, $result);
}
- public function isSlotVarProvider()
+ public static function isSlotVarProvider(): array
{
return [
// 1
@@ -316,13 +327,14 @@ class StringHelperTest extends TestCase
* @param mixed $var
* @param mixed $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('slotVarProvider')]
public function testSlotVar($var, $expected)
{
$result = StringHelper::slotVar($var);
$this->assertSame($expected, $result);
}
- public function slotVarProvider()
+ public static function slotVarProvider(): array
{
return [
['%{slot.var}', 'slot.var'],
diff --git a/tests/etc/tasks/ext/phpunit/tests/provider_failTest.php b/tests/etc/tasks/ext/phpunit/tests/provider_failTest.php
index a60154a..e63da7f 100644
--- a/tests/etc/tasks/ext/phpunit/tests/provider_failTest.php
+++ b/tests/etc/tasks/ext/phpunit/tests/provider_failTest.php
@@ -17,12 +17,13 @@ class provider_failTest extends \PHPUnit\Framework\TestCase
* @param mixed $v1
* @param mixed $v2
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('provider')]
public function testProvider($v1, $v2)
{
$this->assertEquals($v1, $v2);
}
- public function provider()
+ public static function provider(): array
{
return [
[true, true],
|