function testShouldRemoveParents()
 {
     $mapper = new DataMapper($this->db);
     $truck_id = $mapper->save(array('name' => 'truck'));
     $wheel_id = $mapper->save(array('name' => 'wheel', 'paths' => array($truck_id)));
     $mapper->save(array('id' => $wheel_id, 'name' => 'wheel', 'paths' => array()));
     $category = $mapper->load($wheel_id);
     $this->assertEquals(array(), $category['paths'], 'should remove paths');
 }
 function testShouldUpdateAddress()
 {
     $address = array('first_name' => 'Joshua', 'last_name' => 'Ribakoff', 'email' => '*****@*****.**', 'address' => '123 Test St', 'address2' => 'Suite 5', 'city' => 'Port St Lucie', 'state' => 'FL', 'postal' => '00123', 'country' => 'USA', 'phone' => '0101010101', 'fax' => '0202020202');
     $addressMapper = new DataMapper($this->db);
     $id = $addressMapper->save($address);
     $updatedAddress = array('id' => $id, 'first_name' => 'Joshua-updated', 'last_name' => 'Ribakoff-updated', 'email' => '*****@*****.**', 'address' => '123 Test St-updated', 'address2' => 'Suite 5-updated', 'city' => 'Port St Lucie-updated', 'state' => 'FL-updated', 'postal' => '12345', 'country' => 'USA-updated', 'phone' => '111111111', 'fax' => '2222222222');
     $addressMapper = new DataMapper($this->db);
     $id = $addressMapper->save($updatedAddress);
     $loadedAddress = $addressMapper->load($id);
     $this->assertSame($updatedAddress, $loadedAddress, 'should save new address');
 }
 function testShouldSaveCartAndItems()
 {
     $cart = new \Metator\Cart\Cart();
     $cart->add(1, 9.99);
     $cart->add(2, 4.99);
     $cart->setQuantity(2, 2);
     $order = array('items' => $cart, 'created' => '0000-00-00 00:00:00');
     $orderMapper = new DataMapper($this->db);
     $id = $orderMapper->save($order, null);
     $reloaded_order = $orderMapper->load($id);
     $this->assertEquals(array(1, 2), $reloaded_order['items']->items(), 'should save items');
 }
 function testShouldConvertNullToEmptyCategories()
 {
     $product_mapper = new DataMapper($this->db);
     $product = new Product(array('sku' => 'foo2'));
     $product->setCategories(null);
     $product_mapper->save($product);
     $product = $product_mapper->load($product->id());
     $this->assertEquals(array(), $product->getCategories(), 'should convert NULL to empty categories');
 }