Skip to content

Instantly share code, notes, and snippets.

@jsdmultisys
Last active March 26, 2019 07:04
Show Gist options
  • Save jsdmultisys/6d922aae42c28110ee730cdb597acea6 to your computer and use it in GitHub Desktop.
Save jsdmultisys/6d922aae42c28110ee730cdb597acea6 to your computer and use it in GitHub Desktop.
Transaction Test
<?php
/** @test */
public function it_can_create_a_booking_transaction()
{
$service = factory(DeliveryService::class)->create();
$sender = factory(CustomerAccount::class)->create();
$senderAddress = factory(CustomerAddress::class)->create([
'customer_account_id' => $sender->id
]);
$recipient = factory(CustomerAccount::class)->create();
$recipientAddress = factory(CustomerAddress::class)->create([
'customer_account_id' => $recipient->id
]);
$data = [
'order_reference' => time(),
'service_id' => 1,
'delivery_service_id' => $service->id,
'service_cutoff' => $service->next_cutoff->format('Y-m-d H:i:s'),
'sender_name' => $sender->full_name,
'sender_address' => $senderAddress->full_address,
'sender_telephone' => $sender->mobile,
'recipient_name' => $recipient->full_name,
'recipient_address' => $recipientAddress->full_address,
'recipient_telephone' => $recipient->mobile,
'cod_amount' => 0,
'declared_value' => 100,
'box_type' => 'L',
'remarks' => 'test',
'pickup_remarks' => null,
'deliver_remarks' => 'Please be on time.'
];
$deliveryRepo = new DeliveryTransactionRepository(new DeliveryTransaction);
$transaction = $deliveryRepo->createTransaction($data);
$this->assertInstanceOf(DeliveryTransaction::class, $transaction);
$this->assertEquals($data['delivery_service_id'], $transaction->delivery_service_id);
$this->assertEquals($data['service_cutoff'], $transaction->service_cutoff);
$this->assertEquals($data['sender_name'], $transaction->sender_name);
$this->assertEquals($data['sender_address'], $transaction->sender_address);
$this->assertEquals($data['sender_telephone'], $transaction->sender_telephone);
$this->assertEquals($data['recipient_name'], $transaction->recipient_name);
$this->assertEquals($data['recipient_address'], $transaction->recipient_address);
$this->assertEquals($data['recipient_telephone'], $transaction->recipient_telephone);
$this->assertEquals($data['cod_amount'], $transaction->cod_amount);
$this->assertEquals($data['declared_value'], $transaction->declared_value);
$this->assertEquals($data['box_type'], $transaction->box_type);
$this->assertEquals($data['remarks'], $transaction->remarks);
$this->assertEquals($data['pickup_remarks'], $transaction->pickup_remarks);
$this->assertEquals($data['deliver_remarks'], $transaction->deliver_remarks);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment