Skip to content

Instantly share code, notes, and snippets.

@jsdecena
Created October 16, 2017 02:45
Show Gist options
  • Save jsdecena/820725bbfbb4f98098290ec42e3b72ee to your computer and use it in GitHub Desktop.
Save jsdecena/820725bbfbb4f98098290ec42e3b72ee to your computer and use it in GitHub Desktop.
Laracom order edit unit test
/** @test */
public function it_can_update_the_order()
{
$order = factory(Order::class)->create();
$orderRepo = new OrderRepository($order);
$customer = factory(Customer::class)->create();
$courier = factory(Courier::class)->create();
$address = factory(Address::class)->create();
$orderStatus = factory(OrderStatus::class)->create();
$paymentMethod = factory(PaymentMethod::class)->create();
$update = [
'reference' => $this->faker->uuid,
'courier_id' => $courier->id,
'customer_id' => $customer->id,
'address_id' => $address->id,
'order_status_id' => $orderStatus->id,
'payment_method_id' => $paymentMethod->id,
'discounts' => 10.50,
'total_products' => 100,
'tax' => 10.00,
'total' => 100.00,
'total_paid' => 100,
'invoice' => null,
'tracking_no' => $this->faker->uuid, // add this
'bc_no' => $this->faker->uuid // add this
];
$updated = $orderRepo->updateOrder($update);
$this->assertEquals($update['reference'], $updated->reference);
$this->assertEquals($update['discounts'], $updated->discounts);
$this->assertEquals($update['total_products'], $updated->total_products);
$this->assertEquals($update['total_paid'], $updated->total_paid);
$this->assertEquals($update['invoice'], $updated->invoice);
$this->assertEquals($update['tracking_no'], $updated->tracking_no); // add this
$this->assertEquals($update['bc_no'], $updated->bc_no); // add this
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment