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

```╭─/data | Store: US | Env: docker.dev | Debug: (X) | Testing: (X) ╰─$ codecept run -c tests/PyzTe

Posts: 207 🧑🏻‍🚀 - Cadet
╭─/data | Store: US | Env: docker.dev | Debug: (X) | Testing: (X)
╰─$ codecept run -c tests/PyzTest/Zed/SomeModule/
Codeception PHP Testing Framework v4.1.1
Powered by PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
Running with seed:


PyzTest\Zed\SomeModule.Business Tests (1) -----------------------------------------------------------------------
E DoingAThingMapperTest: Whatever
-------------------------------------------------------------------------------------------------------------------------------------

In ConnectionFactory.php line 42:

  Unable to open connection


In PdoAdapter.php line 72:

  Unable to open PDO connection


In PdoConnection.php line 64:

  SQLSTATE[HY000] [2002] Connection refused


.....

╭─/data | Store: US | Env: docker.dev | Debug: (X) | Testing: (X)
    /**
     * @var \PyzTest\Zed\Business\SomeModule
     */
    public $tester;

    /**
     * @return void
     */
    public function testWhatever()
    {

What’s up here?

Welcome!

It looks like you're new here. Sign in or register to get started.

Comments

  • Posts: 118 🧑🏻‍🚀 - Cadet

    Try enabling \SprykerTest\Shared\Propel\Helper\ConnectionHelper in your suite's codeception.yml

  • Posts: 207 🧑🏻‍🚀 - Cadet
    edited July 2021
    suites:
        Business:
            path: Business
            class_name: SomeModule
            modules:
                enabled:
                    - Asserts
                    - \PyzTest\Shared\Testify\Helper\Environment
                    - \SprykerTest\Zed\Testify\Helper\BusinessHelper:
                          projectNamespaces: ['Pyz']
                    - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper
                    - \SprykerTest\Shared\Propel\Helper\TransactionHelper
                    - \SprykerTest\Shared\Propel\Helper\ConnectionHelper
    

    Nope

    I did find that if I remove

    suites:
        Business:
            path: Business
            class_name: SomeModule
            modules:
                enabled:
                    - Asserts
                    - \PyzTest\Shared\Testify\Helper\Environment
                    - \SprykerTest\Zed\Testify\Helper\BusinessHelper:
                          projectNamespaces: ['Pyz']
                    - \SprykerTest\Shared\Testify\Helper\DataCleanupHelper
                    - \SprykerTest\Shared\Propel\Helper\TransactionHelper <- this line
                    - \SprykerTest\Shared\Propel\Helper\ConnectionHelper
    

    the error goes away, but then I assume I lose access to the DB

  • Posts: 118 🧑🏻‍🚀 - Cadet

    I just checked ... TransactionHelper already does the things that ConnectionHelper does so it's not necessary to have them both.
    You could try with \SprykerTest\Shared\Propel\Helper\DatabaseHelper which will configure the database connection. Perhaps that helps with using TransactionHelper

  • Posts: 207 🧑🏻‍🚀 - Cadet

    Fatal error: Uncaught Error: Class 'Codeception\Module\Db' not found

  • Posts: 118 🧑🏻‍🚀 - Cadet
    composer require --dev codeception/module-db
    
  • Posts: 207 🧑🏻‍🚀 - Cadet

    huh ok… that seems unnecessary considering other tests have the Transaction helper enabled… I’ll give it a shot

  • Posts: 118 🧑🏻‍🚀 - Cadet

    But I don't think that's necessary to install. Weird ... perhaps it's simply the database configuration for your test environment that is wrong. Judging from the error message you posted it tried to establish a connection but fails. My first guess was that you're missing the required modules to provide database connectivity but that doesn't seem to be the issue

  • Posts: 207 🧑🏻‍🚀 - Cadet

    no worries thanks I’ll ask the spryker devs on my project, thought it was a more general thing since it died right outta the gate

  • Posts: 118 🧑🏻‍🚀 - Cadet

    So you're saying it works for some tests but not for others?

  • Posts: 207 🧑🏻‍🚀 - Cadet

    no I guess it doesn’t assuming it was working for the other tests, do I need to restart docker or something, did the test variable… did I miss a step

  • Posts: 207 🧑🏻‍🚀 - Cadet

    oh I’m and idiot I think you have to specify

  • Posts: 207 🧑🏻‍🚀 - Cadet

    nope that wasn’t it either… -t and testing seem to do the same thing…

  • Posts: 118 🧑🏻‍🚀 - Cadet

    The issue you have is a pretty common one. When running codeception with the -c option you are targeting a specific suite. When you simply use the -g option (and don't use -c) to target a test case all of the codeception.yml files will get loaded and all the modules they enable will get initialized. Usually one of the suites has the required modules enabled so your test case runs just fine.
    When you use -c on the other hand, only the modules for that particular suite are initialized and it's pretty common that it is missing to enable a couple of required modules.

  • Posts: 207 🧑🏻‍🚀 - Cadet

    ah

  • Posts: 207 🧑🏻‍🚀 - Cadet

    which logically means that one of the tests suites has the answer in enabled

  • Posts: 118 🧑🏻‍🚀 - Cadet

    Since that has happened to me as well in the past, my usual solution is to check if I have all the required database modules enabled, hence my first suggestion

  • Posts: 118 🧑🏻‍🚀 - Cadet

    Yes, the answer should be in one of the other codeception.yml files

  • Posts: 118 🧑🏻‍🚀 - Cadet
    edited July 2021

    Try running your test without the -c option. If that works you're on the right path

  • Posts: 207 🧑🏻‍🚀 - Cadet

    yup ok

    [PyzTest\Zed\SomeModule]: tests from /data/tests/PyzTest/Zed/SomeModule
    
    
    PyzTest\Zed\SomeModule.Business Tests (1) -----------------------------------------------------------------------
    ✔ TestsAThingTest: That inactive items are not on clearance (0.00s)
    -----------------------------------------------------------------------------------------------------
    

Welcome!

It looks like you're new here. Sign in or register to get started.