Class: ODDB::State::PayPal::TestIpn

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_state/paypal/ipn.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



20
21
22
# File 'test/test_state/paypal/ipn.rb', line 20

def setup
  @state = Ipn.new
end

- (Object) test_format_invoice



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'test/test_state/paypal/ipn.rb', line 23

def test_format_invoice
  lookandfeel = FlexMock.new
  lookandfeel.should_receive(:lookup).and_return { |key| key.to_s }
  item1 = FlexMock.new
  item1.should_receive(:quantity).and_return { 1 }
  item1.should_receive(:text).and_return { 'fshort' }
  item1.should_receive(:total_netto).and_return { 12 }
  item2 = FlexMock.new
  item2.should_receive(:quantity).and_return { 12 }
  item2.should_receive(:text).and_return { 'a_longer_filename' }
  item2.should_receive(:total_netto).and_return { 144 }
  invoice = FlexMock.new
  invoice.should_receive(:items).and_return { { 1 => item1, 2 => item2 } }
  invoice.should_receive(:total_netto).and_return { 156 }
  invoice.should_receive(:vat).and_return { 15.6 }
  invoice.should_receive(:total_brutto).and_return { 171.6 }
  result = @state.format_invoice(invoice, lookandfeel)
  expected = "invoice_origin\n\n==================================\n1 x fshort             EUR  12.00\n12 x a_longer_filename  EUR 144.00\n----------------------------------\ntotal_netto        EUR 156.00\n----------------------------------\nvat                EUR  15.60\n==================================\ntotal_brutto       EUR 171.60\n==================================\n"
  assert_equal(expected, result, [expected, result].join("\n<->\n"))
end