Beispiel #1
0
 /**
  * Test that adding an item gives the desired effect
  */
 function test_add_item_basic()
 {
     $order = new APP_Draft_Order();
     $order->add_item('payment-test', 5, $order->get_id());
     // Adding an item should only increase the item count by 1
     $this->assertCount(1, $order->get_items());
     // Adding an item should cause it to be returned
     $this->assertCount(1, $order->get_items('payment-test'));
     $item = $order->get_item();
     $this->assertNotEmpty($item);
     // The correct values should be contained in the item array
     $this->assertArrayHasKey('price', $item);
     $this->assertEquals(5, $item['price']);
     $this->assertArrayHasKey('post_id', $item);
     $this->assertEquals($order->get_id(), $item['post_id']);
     $order->add_item('payment-test', 5, $order->get_id());
     $order->add_item('payment-test', 5, $order->get_id());
     $order->add_item('payment-test1', 5, $order->get_id());
     // Adding additional items should increase the count
     $this->assertCount(4, $order->get_items());
     // APP_Order::get_items should filter items properly
     $this->assertCount(3, $order->get_items('payment-test'));
     // Getting a non-existant item should return false
     $this->assertFalse($order->get_item(10));
 }