foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Codeception support

Open kbond opened this issue 5 years ago • 8 comments

I have never used Codeception so would like help from someone familiar with it to help with possible integration. This is a naive POC that could be a possible starting point.

Do the PHPUnit assertions available on the RepositoryProxy and Proxy objects (ie RepositoryProxy::assertCount()) work with Codeception?

kbond avatar Oct 13 '20 15:10 kbond

Hey @kbond, can you please update the description of this issue with the current challenges of integrating with Codeception?

Is there any way we can convert this into a module like module-datafactory

TavoNiievez avatar Dec 31 '20 00:12 TavoNiievez

Hey @TavoNiievez - I updated the description. Basically, I just need someone who is well acquainted with Codeception to champion the effort to integrate.

Is there any way we can convert this into a module like module-datafactory

I think so but I would like confirmation by someone familiar with the library (ie convert a real project with many tests to use this module).

kbond avatar Dec 31 '20 01:12 kbond

Well, I'm not an expert yet, but I know the symfony module well and worked on its latest versions, the data-factory module doesn't seem to have very complex code... So I think I can help with a Foundry module as well.

(ie convert a real project with many tests to use this module).

We could somehow adapt https://github.com/Codeception/symfony-module-tests so that it can meet that goal.

hopefully, we can make an official module from it.

I think so but I would like confirmation by someone familiar with the library

not to mention more 😄: @Naktibalda @DavertMik Do you think we can collaborate to get this module forward? Starting by answering:

Do the PHPUnit assertions available on the RepositoryProxy and Proxy objects (ie RepositoryProxy::assertCount()) work with Codeception?

TavoNiievez avatar Dec 31 '20 01:12 TavoNiievez

hopefully, we can make an official module from it.

Alternatively, I'm open to having the module live in this library. We could mark it as experimental (so to allow possible BC breaks) and it could act as a POC for an official module if ever desired.

kbond avatar Dec 31 '20 01:12 kbond

Clic to see TavoNiievez's response.

I tried.

I created a module, and I tried the have function, which should receive the fqcn of the entity and the attributes.

Here is the code for the function.

In my functional.suite.yml I have:

actor: FunctionalTester
modules:
    enabled:
        - Foundry:
            depends: Doctrine2
            factories:
                - \App\Factory\UserFactory
        - Symfony:
            app_path: 'src'
            environment: 'test'
        - Doctrine2:
            depends: Symfony
            cleanup: true

and in my test I have:

    $I->have(User::class, [
        'email' => '[email protected]',
        'password' => '123456'
    ]);
    $I->seeNumRecords(1, User::class);

everything goes fine until Foundry tries to create the object 🤣 ​​[line 140]

I am getting the following error:

[InvalidArgumentException] Cannot set attribute "0" for object "App\Entity\User" (not public and no setter).

However, calling Foundry as I do in my fixtures from there also does not work:

    UserFactory::new([
            'email' => '[email protected]',
            'password' => '123456'
    ])->create();

so I guess the problem is another.


TavoNiievez avatar Dec 31 '20 06:12 TavoNiievez

everything goes fine until Foundry tries to create the object rofl ​​[line 140]

I am getting the following error:

I believe [$attributes] should be $attributes.

kbond avatar Jan 01 '21 15:01 kbond

yes, that was it. Thanks you. It works well. I'll continue with the other methods and documentation.

TavoNiievez avatar Jan 01 '21 16:01 TavoNiievez

I finished the first draft:

module-foundry, also in Packagist.

TavoNiievez avatar Jan 01 '21 21:01 TavoNiievez