setAutoload example

if ($repository->findPackage('psr/container', $constraint)) {
      $autoload['classmap'] = array_merge($autoload['classmap'][
        $vendor_dir . '/psr/container/src/ContainerInterface.php',
      ]);
    }
    if ($repository->findPackage('laminas/laminas-zendframework-bridge', $constraint)) {
      $autoload['classmap'] = array_merge($autoload['classmap'][
        $vendor_dir . '/laminas/laminas-zendframework-bridge/src/Autoloader.php',
        $vendor_dir . '/laminas/laminas-zendframework-bridge/src/RewriteRules.php',
      ]);
    }
    $package->setAutoload($autoload);
  }

  /** * Fires the drupal-phpunit-upgrade script event if necessary. * * @param \Composer\Script\Event $event * The event. * * @internal */
  public static function upgradePHPUnit(Event $event) {
    

        $language = new LanguageEntity();
        $language->setId('foo');

        // @phpstan-ignore-next-line         return new StaticEntityRepository([new LanguageCollection([$language])new LanguageCollection([$language])]);
    }

    private function getComposerPackage(): CompletePackage
    {
        $completePackage = new CompletePackage('foo', '1.0.0', '1.0.0');
        $completePackage->setAutoload([
            'psr-4' => [
                'Foo\\' => 'bar',
            ],
        ]);
        $completePackage->setExtra([
            'label' => [
                'en-GB' => 'foo',
            ],
            'description' => [
                'en-GB' => 'foo',
            ],
        ]);
$loader = new StaticKernelPluginLoader($this->classLoader, null, $plugins);

        $this->expectException(KernelPluginLoaderException::class);
        $this->expectExceptionMessage('Failed to load plugin "SwagTest". Reason: Unable to register plugin "SwagTest\SwagTest" in autoload. Required property `autoload` missing.');
        $loader->initializePlugins(TEST_PROJECT_DIR);
    }

    public function testExpectExceptionOnMissingAutoloadPsr(): void
    {
        $active = $this->getActivePlugin();
        $active->setAutoload([]);
        $plugins = [$active->jsonSerialize()];

        $loader = new StaticKernelPluginLoader($this->classLoader, null, $plugins);

        $this->expectException(KernelPluginLoaderException::class);
        $this->expectExceptionMessage('Failed to load plugin "SwagTest". Reason: Unable to register plugin "SwagTest\SwagTest" in autoload. Required property `psr-4` or `psr-0` missing in property autoload.');
        $loader->initializePlugins(TEST_PROJECT_DIR);
    }

    public function testGetPluginInstance(): void
    {
        
Home | Imprint | This part of the site doesn't use cookies.