Sha256: a39d12ca744dceb2ec34bd3083a875940098a0fe05a90f7af1ec124c05098be3

Contents?: true

Size: 1.03 KB

Versions: 6

Compression:

Stored size: 1.03 KB

Contents

require File.join(File.dirname(__FILE__), '../test_helper.rb')

class PaymentTest < Test::Unit::TestCase

  # Tests that a payment can be converted into XML that Xero can understand, and then converted back to a payment
  def test_build_and_parse_xml
    payment = create_test_payment

    # Generate the XML message
    payment_as_xml = payment.to_xml

    # Parse the XML message and retrieve the account element
    payment_element = REXML::XPath.first(REXML::Document.new(payment_as_xml), "/Payment")

    # Build a new account from the XML
    result_payment = XeroGateway::Payment.from_xml(payment_element)

    # Check the details
    assert_equal payment, result_payment
  end


  private

  def create_test_payment
    XeroGateway::Payment.new.tap do |payment|
      payment.invoice_id        = "a99a9aaa-9999-99a9-9aa9-aaaaaa9a9999"
      payment.amount            = 100.0
      payment.date              = Time.now.beginning_of_day
      payment.reference         = "Invoice Payment"
      payment.code              = 200
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
xero_gateway-float-2.1.7 test/unit/payment_test.rb
xero_gateway-float-2.1.6 test/unit/payment_test.rb
xero_gateway-float-2.1.4 test/unit/payment_test.rb
xero_gateway-float-2.1.3 test/unit/payment_test.rb
xero_gateway-float-2.1.1 test/unit/payment_test.rb
xero_gateway-2.1.0 test/unit/payment_test.rb