Level 2
How does the data actually get stored in the DB? It may not be stored as an array or json object.
/** @test */
public function it_successfuly_registers_for_a_delivery()
{
list($user, $program) = $this->arrangeTheWorld();
$address = 'Full Address';
$this->visit('program/register')
->type($user->first_name, 'first_name')
->type($user->last_name, 'last_name')
->type($user->email, 'email')
->type($user->phone, 'phone')
->select($program->id, 'program_id')
->select('deliver', 'shipping_method')
->type($address, 'shipping_address')
->press('Register')
->see('Congrats ' . $user->first_name);
$this->seeInDatabase('users', $user->toArray());
$this->checkAttendees($program, [
'shipping_method' => 'deliver',
'shipping_address' => $address
]);
$this->checkInvoices($program);
}
/**
* @return array
*/
protected function arrangeTheWorld()
{
$user = factory(User::class)->make();
$programs = factory(Program::class, 10)->create([
'name' => 'Detox5',
'type' => 'detox5',
'price' => 65000
]);
$program = $programs->filter(function($program) {
return $program->start_time > Carbon::now()->addDays(2);
})[0];
return [$user, $program];
}
/**
* Check the attendees table
*
* @param Program $program
* @param array $extra
* @return void
*/
protected function checkAttendees($program, $extra)
{
$this->seeInDatabase('attendees', [
'user_id' => 1,
'program_id' => $program->id,
'program_type' => $program->type,
// 'extra' => json_encode($extra)
]);
}
If I check for an array in the DB or json encode it it still doesn't return a green test. With it commented out it gives me a green test.
Please or to participate in this conversation.