aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-11-27 10:40:50 +0100
committerGitHub <noreply@github.com>2023-11-27 10:40:50 +0100
commit3ccb301853ee849c62a3a08b5c7333a615bfa3db (patch)
treee61c745d794f95e9295af30c57700465e8e58d0f /tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
parent011390aacbeed174716a76f9944b5db6757d6d0c (diff)
parent4827fc3eda68042e1c72957c9395f96ae570761d (diff)
downloadnextcloud-server-3ccb301853ee849c62a3a08b5c7333a615bfa3db.tar.gz
nextcloud-server-3ccb301853ee849c62a3a08b5c7333a615bfa3db.zip
Merge pull request #41578 from nextcloud/enh/noid/dispatcher-test-argument-range
Enable AppFramework dispatcher to enforce integer ranges
Diffstat (limited to 'tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php')
-rw-r--r--tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
index 5452fb853b9..2ba2f34425b 100644
--- a/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
+++ b/tests/lib/AppFramework/Utility/ControllerMethodReflectorTest.php
@@ -54,6 +54,14 @@ class MiddleController extends BaseController {
public function test3() {
}
+
+ /**
+ * @psalm-param int<-4, 42> $rangedOne
+ * @psalm-param int<min, max> $rangedTwo
+ * @return void
+ */
+ public function test4(int $rangedOne, int $rangedTwo) {
+ }
}
class EndController extends MiddleController {
@@ -234,4 +242,17 @@ class ControllerMethodReflectorTest extends \Test\TestCase {
$this->assertFalse($reader->hasAnnotation('Annotation'));
}
+
+ public function testRangeDetection() {
+ $reader = new ControllerMethodReflector();
+ $reader->reflect('Test\AppFramework\Utility\EndController', 'test4');
+
+ $rangeInfo1 = $reader->getRange('rangedOne');
+ $this->assertSame(-4, $rangeInfo1['min']);
+ $this->assertSame(42, $rangeInfo1['max']);
+
+ $rangeInfo2 = $reader->getRange('rangedTwo');
+ $this->assertSame(PHP_INT_MIN, $rangeInfo2['min']);
+ $this->assertSame(PHP_INT_MAX, $rangeInfo2['max']);
+ }
}