diff --git a/composer.json b/composer.json index 4926d12..3200f2e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ }, "config": { "optimize-autoloader": true, - "classmap-authoritative": true, "platform": { "php": "8.0" }, diff --git a/tests/Integration/Composer/AutoloaderTest.php b/tests/Integration/Composer/AutoloaderTest.php new file mode 100644 index 0000000..50002d2 --- /dev/null +++ b/tests/Integration/Composer/AutoloaderTest.php @@ -0,0 +1,60 @@ + + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace OCA\WorkflowOcr\Tests\Integration\Composer; + +use OCP\Security\ISecureRandom; +use OCP\Server; +use Test\TestCase; + +class AutoloaderTest extends TestCase { + /** @var null|string */ + private $testClass = null; + + private static function getClassPath(string $class): string { + return __DIR__ . '/../../../lib/' . $class . '.php'; + } + + protected function tearDown(): void { + parent::tearDown(); + + if ($this->testClass !== null && file_exists(self::getClassPath($this->testClass))) { + unlink(self::getClassPath($this->testClass)); + } + } + + public function testLoadDynamicClass(): void { + $rand = Server::get(ISecureRandom::class); + $className = ucfirst($rand->generate(10, ISecureRandom::CHAR_LOWER)); + $namespace = "OCA\\WorkflowOcr"; + + file_put_contents(self::getClassPath($className), <<testClass = $className; + + $this->assertTrue(class_exists($namespace . '\\' . $className)); + } +}