Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot define model #427

Open
StefanGramadnikov opened this issue Jul 20, 2016 · 7 comments
Open

Cannot define model #427

StefanGramadnikov opened this issue Jul 20, 2016 · 7 comments

Comments

@StefanGramadnikov
Copy link

Hi,

I'm using codeception and symfony 2.8 with doctrine 2. I'm writing unit tests with codeception and I want to pre load some data with Factory Muffin, but I'm getting stuck. Here is my setup:

  • Enabled Modules
modules:
    enabled:
        - Asserts
        - Symfony
        - Db
        - Doctrine2:
            depends: Symfony
        - \Helper\Unit
        - DataFactory:
            factories: tests/_support/factories
            depends: Doctrine2

note: I have installed factory muffin and the faker through composer

  • I have the factories folder in tests/_support/factories
  • My factories are in the folder above
  • My factory looks like this
<?php
use League\FactoryMuffin\Faker\Facade as Faker;

$fm->define('AppBundle\Entity\User', [
    'name' => Faker::name(),
    'email' => Faker::email(),
    'isActive' => Faker::boolean(100),
    'isDeleted' => Faker::boolean(0),
    'type' => 'user',
    'apiKey' => 'test'
]);

My problem is that when I run the tests I get ->


[League\FactoryMuffin\Exceptions\DefinitionAlreadyDefinedException]     
The model definition 'AppBundle\Entity\User' has already been defined

I was trying to debug it and saw that the method define in FactoryMuffin.php is being called two times and I couldn't figure out why. The second time is where it throws the exception.

If I try $fm->make instead of define I get

[League\FactoryMuffin\Exceptions\DefinitionNotFoundException]  
 The model definition 'AppBundle\Entity\User' is undefined. 

Can you please tell me if I'm doing something wrong or check if there is some mistake in the code.
If you need more info about my configuration I'll be in touch.

Thank you

@GrahamCampbell
Copy link
Member

Is codeception requiring the file?

@StefanGramadnikov
Copy link
Author

Which file exactly. It is requiring the factory and it is throwing the exception when I call $fm->define().

@Jan-Siva
Copy link

Jan-Siva commented Sep 5, 2017

Hi @StefanGramadnikov ! Did you get any further help on this? I am facing a similar issue.

@tuanmy
Copy link

tuanmy commented Oct 30, 2017

the same issue with me, I am implementing this repo for Codeigniter 3.x. when I define a Model, after run a testcase It throw "The model definition 'User' is undefined"
if I use namespace for Model, it's okay, but I dont want to use namespace for it, I throw above error.
Any guys have solutions to solve this ?? @StefanGramadnikov
@GrahamCampbell

@ctrlaltdylan
Copy link

same issue

@pawelryznar
Copy link

Did any of you the solution? I have the same issue trying to integrate Codeception in ZendExpressive.

@natsu90
Copy link

natsu90 commented May 16, 2022

I'm using ZF2 framework and have similar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants