aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-07-09 14:45:37 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-07-09 14:45:37 +0200
commit8b46dce2f4b546bf7e97a5cf7e11e34bf7d133d1 (patch)
tree849dc5d03f28af5b41e1c5d4a4d2475ea80cc819
parent3da74810b53947cf57b8e12fcca75f325fbe62a4 (diff)
downloadnextcloud-server-fix/fix-di-when-casing-is-wrong.tar.gz
nextcloud-server-fix/fix-di-when-casing-is-wrong.zip
chore: Add tests for DI with incorrect casingfix/fix-di-when-casing-is-wrong
It seems our DI supports classnames with wrong casing and apps rely upon it, add a test to check if that’s true on PHP 8.4 as well. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
index 219fd5134ae..c706ca72689 100644
--- a/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
+++ b/tests/lib/AppFramework/DependencyInjection/DIIntergrationTests.php
@@ -33,6 +33,14 @@ class ClassB {
}
}
+class ClassC {
+ public function __construct(
+ // Intentional wrong casing to check that DI works in this case
+ public interface1 $interface1,
+ ) {
+ }
+}
+
class DIIntergrationTests extends TestCase {
/** @var DIContainer */
private $container;
@@ -58,9 +66,11 @@ class DIIntergrationTests extends TestCase {
);
});
- /** @var ClassB $res */
$res = $this->container->query(ClassB::class);
$this->assertSame(ClassA1::class, get_class($res->interface1));
+
+ $res = $this->container->query(ClassC::class);
+ $this->assertSame(ClassA1::class, get_class($res->interface1));
}
public function testInjectDepFromServer(): void {
@@ -74,9 +84,11 @@ class DIIntergrationTests extends TestCase {
);
});
- /** @var ClassB $res */
$res = $this->container->query(ClassB::class);
$this->assertSame(ClassA1::class, get_class($res->interface1));
+
+ $res = $this->container->query(ClassC::class);
+ $this->assertSame(ClassA1::class, get_class($res->interface1));
}
public function testOverwriteDepFromServer(): void {
@@ -94,9 +106,11 @@ class DIIntergrationTests extends TestCase {
);
});
- /** @var ClassB $res */
$res = $this->container->query(ClassB::class);
$this->assertSame(ClassA2::class, get_class($res->interface1));
+
+ $res = $this->container->query(ClassC::class);
+ $this->assertSame(ClassA2::class, get_class($res->interface1));
}
public function testIgnoreOverwriteInServerClass(): void {
@@ -114,8 +128,10 @@ class DIIntergrationTests extends TestCase {
);
});
- /** @var ClassB $res */
$res = $this->container->query(ClassB::class);
$this->assertSame(ClassA1::class, get_class($res->interface1));
+
+ $res = $this->container->query(ClassC::class);
+ $this->assertSame(ClassA1::class, get_class($res->interface1));
}
}