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

Fabricators documentation error #3743

Closed
luispastendev opened this issue Oct 8, 2020 · 2 comments · Fixed by #3748
Closed

Fabricators documentation error #3743

luispastendev opened this issue Oct 8, 2020 · 2 comments · Fixed by #3748

Comments

@luispastendev
Copy link

luispastendev commented Oct 8, 2020

In the example where they show the getCount functionality, I think there is an error in the code since the table where it should get the random id is from groups, not from users

class UserModel
{
    protected $table = 'users';

    public function fake(Generator &$faker)
    {
            return [
            'first'    => $faker->firstName,
            'email'    => $faker->email,
            'group_id' => rand(1, Fabricator::getCount('groups')), // <---- 
            ];
    }

https://codeigniter.com/user_guide/testing/fabricator.html#table-counts

@paulbalandan
Copy link
Member

I think @MGatner can answer that.

@MGatner
Copy link
Member

MGatner commented Oct 9, 2020

You are absolutely correct! I will patch that.

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

Successfully merging a pull request may close this issue.

3 participants