Browse Source

allow PHPUnit 11

Kevin Pfeifer 1 year ago
parent
commit
e56048ed80

+ 2 - 2
composer.json

@@ -27,13 +27,13 @@
 	},
 	"require": {
 		"php": ">=8.1",
-		"cakephp/cakephp": "^5.0.3",
+		"cakephp/cakephp": "dev-5.next as 5.1.0",
 		"dereuromark/cakephp-shim": "^3.0.0"
 	},
 	"require-dev": {
 		"fig-r/psr2r-sniffer": "dev-master",
 		"mobiledetect/mobiledetectlib": "^3.74",
-		"phpunit/phpunit": "^10.1",
+		"phpunit/phpunit": "^10.5.5 || ^11.1.3",
 		"yangqi/htmldom": "^1.0"
 	},
 	"suggest": {

+ 4 - 2
phpstan.neon

@@ -2,8 +2,6 @@ parameters:
 	level: 6
 	paths:
 		- src/
-	checkMissingIterableValueType: false
-	checkGenericClassInNonGenericObjectType: false
 	treatPhpDocTypesAsCertain: false
 	bootstrapFiles:
 		- %rootDir%/../../../tests/bootstrap.php
@@ -13,6 +11,10 @@ parameters:
 	reportUnmatchedIgnoredErrors: false
 	ignoreErrors:
 		-
+			identifier: missingType.generics
+		-
+			identifier: missingType.iterableValue
+		-
 			message: '#Undefined variable: .+#'
 			path: '%rootDir%/../../../src/View/Helper/TreeHelper.php'
 		-

+ 3 - 2
tests/TestCase/Command/InflectCommandTest.php

@@ -5,12 +5,12 @@ namespace Tools\Test\TestCase\Command;
 
 use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
 use Cake\TestSuite\TestCase;
+use Tools\Command\InflectCommand;
 
 /**
  * Tools\Command\InflectCommand Test Case
- *
- * @uses \Tools\Command\InflectCommand
  */
+#[\PHPUnit\Framework\Attributes\UsesClass(InflectCommand::class)]
 class InflectCommandTest extends TestCase {
 
 	use ConsoleIntegrationTestTrait;
@@ -22,6 +22,7 @@ class InflectCommandTest extends TestCase {
 	 */
 	public function setUp(): void {
 		parent::setUp();
+		$this->loadPlugins(['Tools']);
 		//$this->useCommandRunner();
 	}
 

+ 2 - 3
tests/TestCase/Controller/Admin/IconsControllerTest.php

@@ -5,11 +5,10 @@ namespace Tools\Test\TestCase\Controller\Admin;
 use Cake\Core\Configure;
 use Cake\TestSuite\IntegrationTestTrait;
 use Shim\TestSuite\TestCase;
+use Tools\Controller\Admin\IconsController;
 use Tools\View\Icon\BootstrapIcon;
 
-/**
- * @uses \Tools\Controller\Admin\IconsController
- */
+#[\PHPUnit\Framework\Attributes\UsesClass(IconsController::class)]
 class IconsControllerTest extends TestCase {
 
 	use IntegrationTestTrait;

+ 2 - 3
tests/TestCase/Controller/Admin/ToolsControllerTest.php

@@ -4,10 +4,9 @@ namespace Tools\Test\TestCase\Controller\Admin;
 
 use Cake\TestSuite\IntegrationTestTrait;
 use Shim\TestSuite\TestCase;
+use Tools\Controller\Admin\ToolsController;
 
-/**
- * @uses \Tools\Controller\Admin\ToolsController
- */
+#[\PHPUnit\Framework\Attributes\UsesClass(ToolsController::class)]
 class ToolsControllerTest extends TestCase {
 
 	use IntegrationTestTrait;

+ 3 - 3
tests/TestCase/Controller/ShuntRequestControllerTest.php

@@ -6,10 +6,9 @@ use Cake\Core\Configure;
 use Cake\TestSuite\IntegrationTestTrait;
 use RuntimeException;
 use Shim\TestSuite\TestCase;
+use Tools\Controller\ShuntRequestController;
 
-/**
- * @uses \Tools\Controller\ShuntRequestController
- */
+#[\PHPUnit\Framework\Attributes\UsesClass(ShuntRequestController::class)]
 class ShuntRequestControllerTest extends TestCase {
 
 	use IntegrationTestTrait;
@@ -27,6 +26,7 @@ class ShuntRequestControllerTest extends TestCase {
 	public function setUp(): void {
 		parent::setUp();
 
+		$this->loadPlugins(['Tools']);
 		Configure::write('Config.allowedLanguages', []);
 		Configure::write('Config.defaultLanguage', null);
 	}

+ 1 - 4
tests/TestCase/Utility/ClockTest.php

@@ -5,13 +5,10 @@ namespace Tools\Test\TestCase\Utility;
 use Shim\TestSuite\TestCase;
 use Tools\Utility\Clock;
 
-/**
- * @coversDefaultClass \Tools\Utility\Clock
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(Clock::class)]
 class ClockTest extends TestCase {
 
 	/**
-	 * @covers ::returnElapsedTime
 	 * @return void
 	 */
 	public function testTime() {

+ 1 - 25
tests/TestCase/Utility/UtilityTest.php

@@ -8,9 +8,7 @@ use RuntimeException;
 use Shim\TestSuite\TestCase;
 use Tools\Utility\Utility;
 
-/**
- * @coversDefaultClass \Tools\Utility\Utility
- */
+#[\PHPUnit\Framework\Attributes\CoversClass(Utility::class)]
 class UtilityTest extends TestCase {
 
 	/**
@@ -43,7 +41,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::inArray
 	 * @return void
 	 */
 	public function testInArray() {
@@ -87,7 +84,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::pregMatch
 	 * @return void
 	 */
 	public function testPregMatch() {
@@ -121,7 +117,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::pregMatch
 	 * @return void
 	 */
 	public function testPregMatchWithPatternEscape() {
@@ -141,7 +136,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::pregMatchAll
 	 * @return void
 	 */
 	public function testPregMatchAll() {
@@ -163,7 +157,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::strSplit
 	 * @return void
 	 */
 	public function testStrSplit() {
@@ -176,7 +169,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::typeCast
 	 * @return void
 	 */
 	public function testTypeCast() {
@@ -186,7 +178,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::getClientIp
 	 * @return void
 	 */
 	public function testGetClientIp() {
@@ -195,7 +186,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::fileExists
 	 * @return void
 	 */
 	public function testFileExists() {
@@ -213,7 +203,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::urlExists
 	 * @return void
 	 */
 	public function testUrlExists() {
@@ -225,7 +214,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::getReferer
 	 * @return void
 	 */
 	public function testGetReferer() {
@@ -245,7 +233,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::getHeaderFromUrl
 	 * @return void
 	 */
 	public function testGetHeaderFromUrl() {
@@ -255,7 +242,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::autoPrefixUrl
 	 * @return void
 	 */
 	public function testAutoPrefixUrl() {
@@ -264,7 +250,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::autoPrefixUrl
 	 * @return void
 	 */
 	public function testAutoPrefixUrlWithDetection() {
@@ -273,7 +258,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::cleanUrl
 	 * @return void
 	 */
 	public function testCleanUrl() {
@@ -311,7 +295,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::trimDeep
 	 * @return void
 	 */
 	public function testDeep() {
@@ -343,7 +326,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::trimDeep
 	 * @return void
 	 */
 	public function testDeepTransformNullToString() {
@@ -545,7 +527,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlattenBasic() {
@@ -570,7 +551,6 @@ class UtilityTest extends TestCase {
 	/**
 	 * Test that deeper nested values overwrite higher ones.
 	 *
-	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlatten() {
@@ -591,7 +571,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::arrayFlatten
 	 * @return void
 	 */
 	public function testArrayFlattenAndPreserveKeys() {
@@ -611,7 +590,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::arrayShiftKeys
 	 * @return void
 	 */
 	public function testArrayShiftKeys() {
@@ -632,7 +610,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::logicalAnd
 	 * @return void
 	 */
 	public function testLogicalAnd() {
@@ -656,7 +633,6 @@ class UtilityTest extends TestCase {
 	}
 
 	/**
-	 * @covers ::logicalOr
 	 * @return void
 	 */
 	public function testLogicalOr() {

+ 1 - 1
tests/TestCase/View/Icon/Collector/FontAwesome4CollectorTest.php

@@ -10,12 +10,12 @@ class FontAwesome4CollectorTest extends TestCase {
 	/**
 	 * Show that we are still API compatible/valid.
 	 *
-	 * @dataProvider extensions
 	 *
 	 * @param string $extension
 	 *
 	 * @return void
 	 */
+	#[\PHPUnit\Framework\Attributes\DataProvider('extensions')]
 	public function testCollect(string $extension): void {
 		$path = TEST_FILES . 'font_icon' . DS . 'fa4' . DS . 'variables.' . $extension;