public function testPlaceOrder()
{
//place items in cart
$this->shoppingcart->add($this->mp3player, 2);
$this->shoppingcart->add($this->socks);
$order = $this->shoppingcart->current();
$factory = new ShopMemberFactory();
$member = $factory->create(array('FirstName' => 'James', 'Surname' => 'Brown', 'Email' => '*****@*****.**', 'Password' => 'jbrown'));
$this->assertTrue((bool) $member);
$member->write();
$order->calculate();
//submit checkout page
$this->assertTrue($this->placeOrder('James', 'Brown', '*****@*****.**', '23 Small Street', 'North Beach', 'Springfield', 'Waikato', '1234567', 'NZ', 'jbrown', 'jbrown', $member), "Order placed sucessfully");
$order = Order::get()->byID($order->ID);
//update order variable to db-stored version
$this->assertFalse($this->shoppingcart->current(), "Shopping cart is empty");
$this->assertNotNull($order);
$this->assertEquals(408, $order->GrandTotal(), 'grand total');
$this->assertEquals(408, $order->TotalOutstanding(), 'total outstanding');
$this->assertEquals(0, $order->TotalPaid(), 'total outstanding');
$this->assertEquals($order->Status, 'Unpaid', 'status is "unpaid"');
$this->assertEquals(false, $order->IsSent());
$this->assertEquals(false, $order->IsProcessing());
$this->assertEquals(false, $order->IsPaid());
$this->assertEquals(false, $order->IsCart());
$this->assertEquals('James', $order->FirstName, 'order first name');
$this->assertEquals('Brown', $order->Surname, 'order surname');
$this->assertEquals('*****@*****.**', $order->Email, 'order email');
$shippingaddress = $order->ShippingAddress();
$this->assertEquals('23 Small Street', $shippingaddress->Address, 'order address');
$this->assertEquals('North Beach', $shippingaddress->AddressLine2, 'order address2');
$this->assertEquals('Springfield', $shippingaddress->City, 'order city');
$this->assertEquals('1234567', $shippingaddress->PostalCode, 'order postcode');
$this->assertEquals('NZ', $shippingaddress->Country, 'order country');
$billingaddress = $order->BillingAddress();
$this->assertEquals('23 Small Street', $billingaddress->Address, 'order address');
$this->assertEquals('North Beach', $billingaddress->AddressLine2, 'order address2');
$this->assertEquals('Springfield', $billingaddress->City, 'order city');
$this->assertEquals('1234567', $billingaddress->PostalCode, 'order postcode');
$this->assertEquals('NZ', $billingaddress->Country, 'order country');
$this->assertTrue($order->Member()->exists(), 'member exists now');
$this->assertEquals('James', $order->Member()->FirstName, 'member first name matches');
$this->assertEquals('Brown', $order->Member()->Surname, 'surname matches');
$this->assertEquals('*****@*****.**', $order->Member()->Email, 'email matches');
//not finished...need to find out how to encrypt the same
//$this->assertEquals($order->Member()->Password, Security::encrypt_password('jbrown'),'password matches');
}