Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional errors when using this plugin #25

Closed
mimmi20 opened this issue May 23, 2021 · 5 comments
Closed

Additional errors when using this plugin #25

mimmi20 opened this issue May 23, 2021 · 5 comments

Comments

@mimmi20
Copy link

mimmi20 commented May 23, 2021

I tried to use this plugin, but got the following errors.

  • The service "Laminas\View\HelperPluginManager" was not configured in Laminas\ServiceManager\ServiceManager
  • Internal error: Unable to resolve service "ViewHelperManager" to a factory; are you certain you provided it during configuration

My Tests including the ServiceManager are configured like this:

use Laminas\ServiceManager\Exception\ContainerModificationsNotAllowedException;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\ServiceManager;
use Laminas\View\Helper\HelperInterface;
use Laminas\View\HelperPluginManager;
use Mezzio\BootstrapForm\LaminasView\View\Helper\ConfigProvider;
use Mezzio\Helper\ServerUrlHelper as BaseServerUrlHelper;
use Mezzio\LaminasView\HelperPluginManagerFactory;
use Mezzio\LaminasView\LaminasViewRenderer;
use Mezzio\LaminasView\LaminasViewRendererFactory;
use Mezzio\LaminasViewHelper\Helper\PluginManager as LvhPluginManager;
use Mezzio\LaminasViewHelper\Helper\PluginManagerFactory as LvhPluginManagerFactory;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\TestCase;
use SebastianBergmann\RecursionContext\InvalidArgumentException;

use function file_get_contents;
use function sprintf;
use function str_replace;

use const PHP_EOL;

/**
 * Base class for navigation view helper tests
 */
abstract class AbstractTest extends TestCase
{
    protected ServiceManager $serviceManager;

    /**
     * Path to files needed for test
     */
    protected string $files;

    /**
     * Class name for view helper to test
     */
    protected string $helperName;

    /**
     * View helper
     */
    protected HelperInterface $helper;

    /**
     * Prepares the environment before running a test
     *
     * @throws ContainerModificationsNotAllowedException
     */
    protected function setUp(): void
    {
        $cwd = __DIR__;

        // read navigation config
        $this->files = $cwd . '/_files';

        $sm = $this->serviceManager = new ServiceManager();
        $sm->setAllowOverride(true);

        $sm->setFactory(HelperPluginManager::class, HelperPluginManagerFactory::class);
        $sm->setFactory(LvhPluginManager::class, LvhPluginManagerFactory::class);

        $sm->setFactory(
            'config',
            static fn (): array => [
                'view_helpers' => (new ConfigProvider())->getViewHelperConfig(),
            ]
        );
        $sm->setFactory(LaminasViewRenderer::class, LaminasViewRendererFactory::class);
        $sm->setFactory(BaseServerUrlHelper::class, InvokableFactory::class);

        $sm->setAllowOverride(false);
    }
...

Without this plugin these errors dont occur.

@Slamdunk
Copy link
Owner

This should have been fixed in #22, released in v0.12.5 six days ago, which version do you use?

@mimmi20
Copy link
Author

mimmi20 commented May 24, 2021

This should have been fixed in #22, released in v0.12.5 six days ago, which version do you use?

0.12.6

@Slamdunk
Copy link
Owner

May I ask you if you provided to PHPStan your ServiceManager as described here https://github.com/Slamdunk/phpstan-laminas-framework#configuration ?

@mimmi20
Copy link
Author

mimmi20 commented May 24, 2021

May I ask you if you provided to PHPStan your ServiceManager as described here

No, I have not. I only have a ConfigProvider. The ServiceManager is configured during in the setup method of all tests. The Project I tried to use this, is a library only, not an application.

@mimmi20
Copy link
Author

mimmi20 commented May 24, 2021

Maybe this extension is not usable for my projects.

@mimmi20 mimmi20 closed this as completed May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants