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..

I'm trying to use `SprykerTest\Shared\Sales\Helper\SalesDataHelper->haveOrderFromQuote()` to crea

U01LKKBK97T
U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

I'm trying to use SprykerTest\Shared\Sales\Helper\SalesDataHelper->haveOrderFromQuote() to create a test order. Seems to work basically, but I'm running into issues when using custom pre save plugins.
In Pyz\Zed\Sales\SalesDependencyProvider->getOrderItemExpanderPreSavePlugins() there is a plugin which is located in a different module (ProductAttribute). The plugin itself is calling a function from its module's facade, of course.
When executing the test, it dies telling me that the facade function doesn't exist. This is because the test uses the ProductAttributeFacade from core, not the one on project level.
Any idea what's going wrong here?

Comments

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 πŸ§‘πŸ»β€πŸš€ - Cadet

    \SprykerTest\Shared\Sales\Helper\SalesDataHelper::getSalesFacade()

    check if your plugin uses locator to get ProductAttributeFacade

    return $this->getLocator()->productAttribute()->facade();
    
  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    The plugin doesn't have a getLocator function. Only the auto-generated function getFacade.

    /**
     * @method ProductAttributeFacadeInterface getFacade()
     */
    
  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 πŸ§‘πŸ»β€πŸš€ - Cadet

    I see, maybe the resolver works in a wrong way in the tests env

    \SprykerTest\Shared\Testify\Helper\LocatorHelper::getFacade()

  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Might be.
    The main point is, that I'm not resolving this facade directly in my test.
    In my test I'm using the SalesFacade only. The sales save order stack will then use a plugin which is located in the ProductAttribute module.
    I can tell that we're having the SalesFacade on core level only, but the ProductAttributeFacade on project level.

  • Eugenia Poidenko
    Eugenia Poidenko Sprykee Posts: 145 πŸ§‘πŸ»β€πŸš€ - Cadet

    Have you defined the project namespaces for tests?

    in codeception.yml where you add the helpers, you can configure the locator in the following way:

    suites:
        Presentation:
            ...
            modules:
                enabled:
                  ...
                  - \SprykerTest\Shared\Testify\Helper\LocatorHelper:
                      projectNamespaces: ['Pyz']
    
  • U01LKKBK97T
    U01LKKBK97T Posts: 287 πŸ§‘πŸ»β€πŸš€ - Cadet

    Yes, I did.