I'm new to Laravel and PHP. I have created a migration 'Car' table with columns id, Make, Model, Year.I have used the seeder to make 50 cars using faker. I have written a unit test to test the data type of the year property to be int, but my unit test is failing. Could anyone pls help me on this?
Migration table:
public function up()
{
Schema::create('cars', function (Blueprint $table) {
$table->increments('id');
$table->string('make');
$table->string('model');
$table-> integer('year');
$table->timestamps();
});
Factory:
$factory->define(App\Car::class, function (Faker $faker) {
return [
'make' => $faker->randomElement($array = array ('Ford','Honda','Toyota')),
'model' => $faker->name,
'year' => $faker->year($max = 'now'),
Seeder
public function run()
{
factory(App\Car::class, 50)->create()->each(function ($car)
}
Unit test
public function testCarYearDataType()
{
$car = Car::find(1);
dd($car->year);
dd(gettype($car->Year));
this->assertInternalType('int',$car->Year);
}