Codeception / Codeception/module-laminas

Documentation how to mock controller plugin factory

Offen
#28 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
PHP
Sterne
1
Forks
7
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello, i am trying to mock factory for controller plugin `FooPlugin`.

```
$this->getServiceLocator()->setAllowOverride( true );

$controllerPluginManager = $this->getServiceLocator()->get( 'ControllerPluginManager' );
$controllerPluginManager->setAllowOverride( true );
$controllerPluginManager->setFactory( FooPlugin::class, FooPluginTestFactory::class );
$controllerPluginManager->setAllowOverride( false );

$this->getModule( Laminas::class )->client->addServiceToContainer( 'ControllerPluginManager', $controllerPluginManager);

$this->getServiceLocator()->setAllowOverride( false );
```

i debugged internal code and see that Laminas overrides my factory `FooPluginTestFactory` to basic `FooPluginFactory`, which is provided in basic config. it occurred indside this https://github.com/Codeception/module-laminas/blob/00d6cf8ae6a10ef52b3569febf1d6277d7b3b8e1/src/Codeception/Lib/Connector/Laminas.php#L196-L205

after next line:
```
// Load modules
$serviceManager->get('ModuleManager')->loadModules();
```

do i make something wrong?
what is the suggested way to make it correctly?

thanks!

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.