function test_get_nearest_descendant_of_type()
 {
     $txn = $this->new_typical_transaction();
     $line_item = $txn->total_line_item();
     $old_tax_subtotal = EEH_Line_Item::get_nearest_descendant_of_type($line_item, EEM_Line_Item::type_tax_sub_total);
     $this->assertInstanceOf('EE_Line_Item', $old_tax_subtotal);
     $this->assertEquals(EEM_Line_Item::type_tax_sub_total, $old_tax_subtotal->type());
     $old_tax = EEH_Line_Item::get_nearest_descendant_of_type($line_item, EEM_Line_Item::type_tax);
     $this->assertInstanceOf('EE_Line_Item', $old_tax_subtotal);
     $this->assertEquals(EEM_Line_Item::type_tax, $old_tax->type());
 }
 /**
  * 	test_set_tax
  */
 function test_set_tax()
 {
     //first create a line item
     $txn = $this->new_typical_transaction();
     $line_item = $txn->total_line_item();
     $old_tax_subtotal = EEH_Line_Item::get_nearest_descendant_of_type($line_item, EEM_Line_Item::type_tax_sub_total);
     $this->assertInstanceOf('EE_Line_Item', $old_tax_subtotal);
     $old_tax = EEH_Line_Item::get_nearest_descendant_of_type($old_tax_subtotal, EEM_Line_Item::type_tax);
     $new_tax = EEH_Line_Item::set_total_tax_to($line_item, 1.5, 'Monkey Tax', 'Only monkey must pay');
     $this->assertEquals(1.5, $new_tax->total());
     $this->assertEquals($new_tax->total(), $old_tax_subtotal->total());
     $child_of_tax_subtotal = EEH_Line_Item::get_nearest_descendant_of_type($old_tax_subtotal, EEM_Line_Item::type_tax);
     $this->assertEquals($new_tax, $child_of_tax_subtotal);
     $tax_total_before_recalculation = $old_tax_subtotal->total();
     $tax_before_recalculations = $new_tax->total();
     $line_item->recalculate_taxes_and_tax_total();
     $this->assertEquals($tax_before_recalculations, $new_tax->total());
     $this->assertEquals($tax_total_before_recalculation, $old_tax_subtotal->total());
 }
 /**
  * @deprecated
  * @param string $type like one of the EEM_Line_Item::type_*
  * @return EE_Line_Item
  */
 public function get_nearest_descendant_of_type($type)
 {
     EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0');
     EE_Registry::instance()->load_helper('Line_Item');
     return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
 }
 /**
  * @deprecated
  * @param string $type like one of the EEM_Line_Item::type_*
  * @return EE_Line_Item
  */
 public function get_nearest_descendant_of_type($type)
 {
     EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0');
     return EEH_Line_Item::get_nearest_descendant_of_type($this, $type);
 }