Level 60
Model Factories and assertDatabaseHas
Summer Sale! All accounts are 50% off this week.
Is there a cleaner way to assert that all these fields have been correctly updated?
$this->post(route('organizations.update', [$site->id, get_class($site)]), [
'email' => $testEmail = '[email protected]',
'telephone' => $testTelephone = '12309174',
'zip' => $testZip = '12345',
'name' => $testName = 'test name',
'street_name' => $testStreetName = 'test street name',
'street_number' => $testStreetNumber = 'test street number',
'city' => $testCity = 'test city',
'country' => $testCountry = fake()->randomElement(CountryEnum::cases())->value,
'state' => $testState = 'test state',
'contracting_times' => $testContractingTimes = 24,
'ethics_committee' => $testEthicsCommittee = 'test committee',
'avatar' => $avatar = UploadedFile::fake()->create('avatar.png', 4096),
])->assertRedirect(route('sites.show', $site->id));
$this->assertEquals($site->name, $testName);
$this->assertEquals($site->contactInformation->email, $testEmail);
$this->assertEquals($site->contactInformation->telephone, $testTelephone);
$this->assertEquals($site->contactInformation->zip, $testZip);
$this->assertEquals($site->contactInformation->street_name, $testStreetName);
$this->assertEquals($site->contactInformation->street_number, $testStreetNumber);
$this->assertEquals($site->contactInformation->city, $testCity);
$this->assertEquals($site->contactInformation->country, $testCountry);
$this->assertEquals($site->contactInformation->state, $testState);
$this->assertEquals($site->metaInformation->contracting_times, $testContractingTimes);
$this->assertEquals($site->metaInformation->ethics_committee, $testEthicsCommittee);
Please or to participate in this conversation.