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

Auto-generated test file is dealing created_at and updated_at as string #498

skys215 opened this issue Oct 25, 2017 · 1 comment


None yet
3 participants
Copy link

commented Oct 25, 2017


I found that when I use infyom:scaffold and infyom:api_scaffold, the auto-generated test is dealing created_at and updated_at as string, not timestamp.

The problem is at genreateFields function in Generators/TestTraitGenerator.php#L49.

The fieldType of created_at and updated_at is timestamp and the function doesn't have such case in the switch($field->fieldType) {, so it was dealt as the default:$fakerData = 'word';.

I forgot to mention that I've upgraded to Laravel 5.5 by myself. Maybe this is the reason.


This comment has been minimized.

Copy link

commented Oct 25, 2017

BTW, should faker set created_at and updated_at?

I'm facing the problem that if created_at and updated_at is set in the Make$MODEL_NAME$Triat.php@fake$MODEL_NAME$Data, then it won't pass the test.

Because the datetime which faker created will never match the time DB inserted since created_at and updated_at is not fillable and DB will set the value when it is inserted.

In that case, it should be ignored while checking in the ApiTestTrait.php@assertModelData.

But I'm new to TDD, I can't imagine if there's possibility to check created_at or updated_at in the test case or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.