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

Hello, I am trying to write tests for my Facade but I am getting the error when I run them ```[Spryk

U01E6Q6AMHC
U01E6Q6AMHC Posts: 48 πŸ§‘πŸ»β€πŸš€ - Cadet
edited December 2020 in Help

Hello, I am trying to write tests for my Facade but I am getting the error when I run them

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

However, I have the TermBusinessFactory class: Pyz\Zed\Term\Business\TermBusinessFactory extends AbstractBusinessFactory. My codeception.yml looks like this:

namespace: PyzTest\Zed\Term

paths:
    tests: .
    data: _data
    support: _support
    log: _output

coverage:
    enabled: true
    remote: false
    whitelist: { include: ['../../../../src/*'] }

suites:
    Business:
        path: Business
        class_name: TermBusinessTester
        modules:
            enabled:
                - Asserts
                - \PyzTest\Shared\Testify\Helper\Environment
                - \SprykerTest\Shared\Testify\Helper\ConfigHelper
                - \SprykerTest\Shared\Testify\Helper\DependencyHelper
                - \SprykerTest\Shared\Propel\Helper\TransactionHelper
                - \SprykerTest\Shared\Testify\Helper\LocatorHelper:
                      projectNamespaces: ['Pyz']

And it fails when I am trying to receive a facade in my FacadeTest:

$termFacade = $this->tester->getLocator()->term()->facade();

I'll post the screenshot of the Zed\Term module structure in the thread.

The implementation itself works, so it looks like a test configuration for class resolvers.

Comments

  • Alberto Reyer
    Alberto Reyer Lead Spryker Solution Architect / Technical Director Posts: 690 πŸͺ - Explorer
    edited December 2020

    ~Facade is wrongly named.~
    ~It needs to be TermBusinessFacade to work~

    Sorry that was wrong, mixed up Facade and Factory in my head.

  • UK7KBE2JW
    UK7KBE2JW Posts: 463 πŸ§‘πŸ»β€πŸš€ - Cadet

    Have u tryed to

    use LocatorHelperTrait;
    

    ?

  • U01E6Q6AMHC
    U01E6Q6AMHC Posts: 48 πŸ§‘πŸ»β€πŸš€ - Cadet

    Unfortunately not.

  • U01E6Q6AMHC
    U01E6Q6AMHC Posts: 48 πŸ§‘πŸ»β€πŸš€ - Cadet

    The working solution is to bypass locator and instantiate the Facade as new TermFacade().

  • U01E6Q6AMHC
    U01E6Q6AMHC Posts: 48 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited December 2020

    However I've noticed that whenever I try to use DataBuilder I'll get the following error:

     Fatal error:  Cannot redeclare non static Spryker\Shared\Testify\AbstractDataBuilder::$faker as static Generated\Shared\DataBuilder\CustomerBuilder::$faker in /data/shop/development/current/src/Generated/Shared/DataBuilder/CustomerBuilder.php on line 16
    

    Usage:

    $customerTransfer = (new CustomerBuilder([]))->build();
    
  • UK7KBE2JW
    UK7KBE2JW Posts: 463 πŸ§‘πŸ»β€πŸš€ - Cadet
    edited December 2020

    Sorry, have to pass here. Nerver used testify to write my tests. I write tests directly for everything

  • U01E6Q6AMHC
    U01E6Q6AMHC Posts: 48 πŸ§‘πŸ»β€πŸš€ - Cadet

    I am just following the documentation / vendor examples