laracasts / TestDummy

Easy factories for PHP integration testing.
https://laracasts.com/lessons/whats-new-in-testdummy
MIT License
456 stars 80 forks source link

How to make a field required? Skipping a field when creating object? #38

Closed mikeerickson closed 10 years ago

mikeerickson commented 10 years ago

I am not sure why this is failing, but it is. Here is my fixture for the contact table

Contact: last_name: $string first_name: $string email: $string@$string.com active: $boolean companies_id: type: Company user_id: type: User

When it generates the test object, the SQL produces an error

Illuminate\Database\QueryException: SQLSTATE[23000]: Integrity constraint violation: 19 contacts.first_name may not be NULL (SQL: insert into "contacts" ("last_name", "email", "active", "companies_id", "user_id", "updated_at", "created_at") values (consequatur, sit@quia.com, 0, 1, 2, 2014-10-30 15:32:05, 2014-10-30 15:32:05))

Not quite sure why "first_name" field is being skipped. Is there a way in which I can mark the field as required?

mikeerickson commented 10 years ago

Turns out this issue is not with TestDummy (sorry @JeffreyWay) but rather there seems to be an issue when creating using Eloquent -- it is literally skipping a field?