That is odd. It seems that the email is working correctly in an earlier part of your code right?
$this->payBidReserve($job, [
'email' => $user->email,
Does the user object still exist in the last part of your test?
Have been working on this test for a while with help from a previous post.
I'm really happy to get the paymentGateway working after a few days by myself without posting. That was a tough thing to get passing.
Hit a snag here, it's so close but thought someone more experienced can help out.
I know it's a very basic thing, but I've tried using some techniques here: https://www.php.net/manual/en/sdo.sample.getset.php
and my favorite error was this one! ErrorException: Indirect modification of overloaded property App\User::$email has no effect
/** @test */
public function an_authenticated_bidder_can_pay_bidreserve_fee()
{
$this->withoutExceptionHandling();
$user = factory(User::class)->create();
$job = factory(Job::class)->create();
$this->actingAs($user);
// dd($user->email);
$this->payBidReserve($job, [
'email' => $user->email,
'bidreserve' => 500,
'payment_token' => $this->paymentGateway->getValidTestToken()
]);
// dd($this->paymentGateway->getValidTestToken());
// dd($this->response);
$this->response->assertStatus(201);
$this->assertCount(1, $job->bidReserves);
// Make sure customer was charged correct amount
$this->assertEquals(500, $this->paymentGateway->totalCharges());
// dd($job);
// Make sure order exists for customer
$bidderEmail = $user->email;
// dd($bidderEmail);
// dd($user->email); $company->departments[0]
$order = $job->ordersFor($bidderEmail)->first();
dd($order);
$this->assertEquals($user->email, $order->email);
// dd($order);
// dd($job->bidReserves);
}
The $user->email property reliably spits out a faker email such as ... "[email protected]"
However, when it's placed as an argument for ordersFor() it returns null. If as shown above I get the property put in a variable it returns ErrorException: Undefined variable: bidderEmail.
Why is that?
//Job.php
public function ordersFor($bidderEmail)
{
return $this->orders()->where('email', $bidderEmail)->get();
}
thank you ~
Please or to participate in this conversation.