What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hey! I am trying to use `$this->tester->getLocator()->product()->facade()` in a codecept

UPPB2H525
UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet
edited August 2020 in Help

Hey!
I am trying to use $this->tester->getLocator()->product()->facade() in a codeception unit test.
This leads to an exception about missing factory.

[Spryker\Zed\Kernel\ClassResolver\Factory\FactoryNotFoundException] Spryker Kernel Exception
Can not resolve ProductBusinessFactory in Business layer for your module "Product"
You can fix this by adding the missing Factory to your module.
E.g. Pyz\Zed\Product\Business\ProductBusinessFactory

In my codeception.yml the following modules are enabled:

                - Asserts
                - \PyzTest\Shared\Testify\Helper\Environment
                - \SprykerTest\Shared\Testify\Helper\LocatorHelper:
                    projectNamespaces: ['Pyz']
                - \SprykerTest\Shared\Testify\Helper\DependencyHelper
                - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper
                - \SprykerTest\Shared\Propel\Helper\TransactionHelper

In fact the factory exists, even on project level, and, of course, on vendor level.

Any ideas whats going wrong?

Comments

  • Unknown
    edited August 2020

    This is usually a typo in the Factory's name. The error is pretty common though

  • Does it extend AbstractFactory?

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    The name of the project level factory is Pyz\Zed\Product\Business\ProductBusinessFactory . It extends Spryker\Zed\Product\Business\ProductBusinessFactory on project level and this one extends AbstractBusinessFactory

  • Check namespace, maybe problem there

  • Of folder naming

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    Is it possible that this is a bug?
    I am asking because https://github.com/spryker/kernel/blob/master/src/Spryker/Zed/Kernel/ClassResolver/Factory/FactoryResolver.php#L21 => protected const RESOLVABLE_TYPE = 'ZedFactory';

    But in https://github.com/spryker/kernel/blob/master/src/Spryker/Shared/Kernel/ClassResolver/AbstractClassResolver.php#L240
    $this->getResolvableTypeClassNamePatternMap() returns an array as visible in attached screenshot.

    There is no key ZedFactory so classNamePattern is null and factory can not be resolved...

    If i change it to protected const RESOLVABLE_TYPE = 'ZedFactoryBusiness'; it works as expected.

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    I am on kernel 3.55, which is the latest version.

  • \Spryker\Zed\Kernel\ClassResolver\Business\BusinessFactoryResolver::RESOLVABLE_TYPE

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited August 2020

    Yes, but this class seems not to be used...

    /data/vendor/spryker/kernel/src/Spryker/Zed/Kernel/ClassResolver/Factory/FactoryNotFoundException.php:49
    /data/vendor/spryker/kernel/src/Spryker/Zed/Kernel/ClassResolver/Factory/FactoryNotFoundException.php:23
    /data/vendor/spryker/kernel/src/Spryker/Zed/Kernel/ClassResolver/Factory/FactoryResolver.php:38
    /data/vendor/spryker/testify/src/Spryker/Zed/Testify/Locator/Business/BundleProxy.php:110
    /data/vendor/spryker/testify/src/Spryker/Zed/Testify/Locator/Business/BundleProxy.php:67
    /data/vendor/spryker/testify/src/Spryker/Zed/Testify/Locator/Business/BundleProxy.php:52
    
    
  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    Ah may be its a wrong spryker/testify version

  • you need at least 3.25.0

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    that seems to be the problem. i am on 3.20.
    I will update and give feedback here. thanks a lot up to here

  • UPPB2H525
    UPPB2H525 Posts: 51 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yep, that helps... Thanks for your input! πŸ‘

  • Good to hear!