archerfinley-google4r-checkout-1.0.5 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +93 -0
- data/LICENSE +22 -0
- data/README +58 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/google4r-checkout-1.0.5-1.0.5.gem +0 -0
- data/google4r-checkout-1.0.5.gemspec +174 -0
- data/lib/google4r/checkout.rb +34 -0
- data/lib/google4r/checkout/commands.rb +567 -0
- data/lib/google4r/checkout/frontend.rb +210 -0
- data/lib/google4r/checkout/merchant_calculation.rb +321 -0
- data/lib/google4r/checkout/notifications.rb +708 -0
- data/lib/google4r/checkout/shared.rb +1086 -0
- data/lib/google4r/checkout/utils.rb +94 -0
- data/lib/google4r/checkout/xml_generation.rb +880 -0
- data/test/integration/checkout_command_test.rb +174 -0
- data/test/unit/add_merchant_order_number_command_test.rb +70 -0
- data/test/unit/add_tracking_data_command_test.rb +75 -0
- data/test/unit/address_test.rb +131 -0
- data/test/unit/anonymous_address_test.rb +75 -0
- data/test/unit/archive_order_command_test.rb +66 -0
- data/test/unit/area_test.rb +44 -0
- data/test/unit/authorization_amount_notification_test.rb +69 -0
- data/test/unit/authorize_order_command_test.rb +66 -0
- data/test/unit/backorder_items_command_test.rb +83 -0
- data/test/unit/callback_handler_test.rb +83 -0
- data/test/unit/cancel_items_command_test.rb +89 -0
- data/test/unit/cancel_order_command_test.rb +83 -0
- data/test/unit/carrier_calculated_shipping_test.rb +57 -0
- data/test/unit/charge_amount_notification_test.rb +64 -0
- data/test/unit/charge_order_command_test.rb +77 -0
- data/test/unit/chargeback_amount_notification_test.rb +65 -0
- data/test/unit/checkout_command_test.rb +125 -0
- data/test/unit/checkout_command_xml_generator_test.rb +218 -0
- data/test/unit/command_test.rb +116 -0
- data/test/unit/deliver_order_command_test.rb +70 -0
- data/test/unit/delivery_method_test.rb +42 -0
- data/test/unit/digital_content_test.rb +105 -0
- data/test/unit/flat_rate_shipping_test.rb +132 -0
- data/test/unit/frontend_test.rb +144 -0
- data/test/unit/item_info_test.rb +69 -0
- data/test/unit/item_test.rb +171 -0
- data/test/unit/marketing_preferences_test.rb +65 -0
- data/test/unit/merchant_calculated_shipping_test.rb +172 -0
- data/test/unit/merchant_calculation_callback_test.rb +137 -0
- data/test/unit/merchant_calculation_result_test.rb +78 -0
- data/test/unit/merchant_calculation_results_test.rb +178 -0
- data/test/unit/merchant_code_result_test.rb +51 -0
- data/test/unit/merchant_code_test.rb +122 -0
- data/test/unit/new_order_notification_test.rb +115 -0
- data/test/unit/notification_acknowledgement_test.rb +67 -0
- data/test/unit/notification_handler_test.rb +113 -0
- data/test/unit/order_adjustment_test.rb +119 -0
- data/test/unit/order_report_command_test.rb +111 -0
- data/test/unit/order_state_change_notification_test.rb +158 -0
- data/test/unit/pickup_shipping_test.rb +70 -0
- data/test/unit/postal_area_test.rb +71 -0
- data/test/unit/private_data_parser_test.rb +68 -0
- data/test/unit/refund_amount_notification_test.rb +65 -0
- data/test/unit/refund_order_command_test.rb +86 -0
- data/test/unit/reset_items_shipping_information_command_test.rb +83 -0
- data/test/unit/return_items_command_test.rb +83 -0
- data/test/unit/risk_information_notification_test.rb +98 -0
- data/test/unit/send_buyer_message_command_test.rb +73 -0
- data/test/unit/ship_items_command_test.rb +101 -0
- data/test/unit/shipping_adjustment_test.rb +100 -0
- data/test/unit/shopping_cart_test.rb +146 -0
- data/test/unit/tax_rule_test.rb +70 -0
- data/test/unit/tax_table_test.rb +82 -0
- data/test/unit/tracking_data_test.rb +54 -0
- data/test/unit/unarchive_order_command_test.rb +66 -0
- data/test/unit/us_country_area_test.rb +76 -0
- data/test/unit/us_state_area_test.rb +70 -0
- data/test/unit/us_zip_area_test.rb +66 -0
- data/test/unit/world_area_test.rb +48 -0
- data/var/cacert.pem +7815 -0
- metadata +189 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/pickup_shipping_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the PickupShipping class.
|
35
|
+
class Google4R::Checkout::PickupShippingMethodTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@shipping = PickupShipping.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_initialization
|
43
|
+
assert_nil @shipping.name
|
44
|
+
assert_nil @shipping.price
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_pickup_shipping_method_behaves_correctly
|
48
|
+
[ :name, :name=, :price, :price= ].each do |sym|
|
49
|
+
assert_respond_to @shipping, sym
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_pickup_shipping_method_setting_attributes_works_correctly
|
54
|
+
@shipping.name = "Shipping Method Name"
|
55
|
+
assert_equal "Shipping Method Name", @shipping.name
|
56
|
+
|
57
|
+
@shipping.price = Money.new(100, "EUR")
|
58
|
+
assert_kind_of Money, @shipping.price
|
59
|
+
assert_equal 100, @shipping.price.cents
|
60
|
+
assert_equal "EUR", @shipping.price.currency
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_pickup_shipping_method_price_is_validated
|
64
|
+
# Test that PickupShippingMethod checks for its price attribute responding
|
65
|
+
# to cents and currency.
|
66
|
+
assert_raises(RuntimeError) { @shipping.price = nil }
|
67
|
+
assert_raises(RuntimeError) { @shipping.price = 10 }
|
68
|
+
assert_raises(RuntimeError) { @shipping.price = "str" }
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'google4r/checkout'
|
2
|
+
|
3
|
+
require 'test/frontend_configuration'
|
4
|
+
#--
|
5
|
+
# Project: google_checkout4r
|
6
|
+
# File: test/unit/area_test.rb
|
7
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
8
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
9
|
+
# License: MIT License as follows:
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
# a copy of this software and associated documentation files (the
|
13
|
+
# "Software"), to deal in the Software without restriction, including
|
14
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
16
|
+
# persons to whom the Software is furnished to do so, subject to the
|
17
|
+
# following conditions:
|
18
|
+
#
|
19
|
+
# The above copyright notice and this permission notice shall be included
|
20
|
+
# in all copies or substantial portions of the Software.
|
21
|
+
#
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
23
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
25
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
26
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
27
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
28
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
|
+
#++
|
30
|
+
|
31
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
32
|
+
|
33
|
+
require 'google4r/checkout'
|
34
|
+
|
35
|
+
require 'test/frontend_configuration'
|
36
|
+
|
37
|
+
# Test for the class Area.
|
38
|
+
class Google4R::Checkout::PostalAreaTest < Test::Unit::TestCase
|
39
|
+
include Google4R::Checkout
|
40
|
+
|
41
|
+
def setup
|
42
|
+
@area = PostalArea.new('GB', 'S6*')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_initialization_works
|
46
|
+
assert_equal 'GB' , @area.country_code
|
47
|
+
assert_equal 'S6*', @area.postal_code_pattern
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_us_state_area_behaves_correctly
|
51
|
+
assert_respond_to @area, :country_code
|
52
|
+
assert_respond_to @area, :country_code=
|
53
|
+
assert_respond_to @area, :postal_code_pattern
|
54
|
+
assert_respond_to @area, :postal_code_pattern=
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_accessors_should_work
|
58
|
+
@area.postal_code_pattern = '100*'
|
59
|
+
assert_equal '100*', @area.postal_code_pattern
|
60
|
+
|
61
|
+
@area.country_code = 'DE'
|
62
|
+
assert_equal 'DE', @area.country_code
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_initialize_without_postcode_works
|
66
|
+
pa = PostalArea.new('DE')
|
67
|
+
assert_equal 'DE', pa.country_code
|
68
|
+
assert_nil pa.postal_code_pattern
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/private_data_parser_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class PrivateDataParser.
|
35
|
+
class Google4R::Checkout::PrivateDataParserTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@xml_str1 = %q{<merchant-private-item-data>
|
40
|
+
<item-note>Text 1</item-note>
|
41
|
+
<item-note>Text 2</item-note>
|
42
|
+
<nested>
|
43
|
+
<tags>value</tags>
|
44
|
+
</nested>
|
45
|
+
</merchant-private-item-data>}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_responds_correctly
|
49
|
+
assert_respond_to PrivateDataParser, :element_to_value
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_parser_works_in_simple_example
|
53
|
+
element = REXML::Document.new(@xml_str1).root.elements['//tags']
|
54
|
+
|
55
|
+
assert_equal 'value', PrivateDataParser.element_to_value(element)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_parser_works_in_complex_example
|
59
|
+
doc = REXML::Document.new(@xml_str1)
|
60
|
+
|
61
|
+
hash =
|
62
|
+
{
|
63
|
+
'item-note' => [ 'Text 1', 'Text 2' ],
|
64
|
+
'nested' => { 'tags' => 'value' }
|
65
|
+
}
|
66
|
+
assert_equal hash, PrivateDataParser.element_to_value(doc.root)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/refund_amount_notification_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan AT gmail.com>
|
5
|
+
# Copyright: (c) 2007 by Tony Chan
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
require 'rexml/document'
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class RefundAmountNotification
|
35
|
+
class Google4R::Checkout::RefundAmountNotificationTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@frontend.tax_table_factory = TestTaxTableFactory.new
|
41
|
+
|
42
|
+
@example_xml = %q{
|
43
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<refund-amount-notification xmlns="http://checkout.google.com/schema/2"
|
45
|
+
serial-number="d669f8c7-6d75-4ad6-9278-d2fc997d15f2">
|
46
|
+
<google-order-number>841171949013218</google-order-number>
|
47
|
+
<latest-refund-amount currency="GBP">226.06</latest-refund-amount>
|
48
|
+
<total-refund-amount currency="GBP">226.06</total-refund-amount>
|
49
|
+
<timestamp>2006-03-18T20:25:31</timestamp>
|
50
|
+
</refund-amount-notification>
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_create_from_element_works_correctly
|
55
|
+
root = REXML::Document.new(@example_xml).root
|
56
|
+
|
57
|
+
notification = RefundAmountNotification.create_from_element(root, @frontend)
|
58
|
+
|
59
|
+
assert_equal 'd669f8c7-6d75-4ad6-9278-d2fc997d15f2', notification.serial_number
|
60
|
+
assert_equal '841171949013218', notification.google_order_number
|
61
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.timestamp
|
62
|
+
assert_equal(Money.new(22606, 'GBP'), notification.total_refund_amount)
|
63
|
+
assert_equal(Money.new(22606, 'GBP'), notification.latest_refund_amount)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/refund_order_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Tony Chan
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the RefundOrderCommand class.
|
35
|
+
class Google4R::Checkout::RefundOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_refund_order_command
|
41
|
+
@command.google_order_number = '841171949013218'
|
42
|
+
@command.amount = Money.new(1000, 'USD')
|
43
|
+
@command.comment = 'Discount for inconvenience; ship replacement item'
|
44
|
+
@command.reason = 'Damaged Merchandise'
|
45
|
+
|
46
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
+
<refund-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
+
<amount currency='USD'>10.00</amount>
|
49
|
+
<comment>Discount for inconvenience; ship replacement item</comment>
|
50
|
+
<reason>Damaged Merchandise</reason>
|
51
|
+
</refund-order>}
|
52
|
+
|
53
|
+
@sample_reason_only=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
54
|
+
<refund-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
55
|
+
<reason>Damaged Merchandise</reason>
|
56
|
+
</refund-order>}
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_behaves_correctly
|
60
|
+
[ :google_order_number, :amount, :reason, :comment ].each do |symbol|
|
61
|
+
assert_respond_to @command, symbol
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_xml_with_amount
|
66
|
+
@command.amount = nil
|
67
|
+
@command.comment = nil
|
68
|
+
assert_strings_equal(@sample_reason_only, @command.to_xml)
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_accessors
|
72
|
+
assert_equal('841171949013218', @command.google_order_number)
|
73
|
+
assert_equal(Money.new(1000, 'USD'), @command.amount)
|
74
|
+
assert_equal('Discount for inconvenience; ship replacement item', @command.comment)
|
75
|
+
assert_equal('Damaged Merchandise', @command.reason)
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_xml_generation
|
79
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_to_xml_does_not_raise_exception
|
83
|
+
assert_nothing_raised { @command.to_xml }
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/reset_items_shipping_information_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Dan Dukeson
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the ResetItemsShippingInformationCommand class.
|
35
|
+
class Google4R::Checkout::ResetItemsShippingInformationCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_reset_items_shipping_information_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.send_email = true
|
44
|
+
@item_info1 = ItemInfo.new('A1')
|
45
|
+
@item_info2 = ItemInfo.new('B2')
|
46
|
+
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
+
|
48
|
+
|
49
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
50
|
+
<reset-items-shipping-information xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
51
|
+
<item-ids>
|
52
|
+
<item-id>
|
53
|
+
<merchant-item-id>A1</merchant-item-id>
|
54
|
+
</item-id>
|
55
|
+
<item-id>
|
56
|
+
<merchant-item-id>B2</merchant-item-id>
|
57
|
+
</item-id>
|
58
|
+
</item-ids>
|
59
|
+
<send-email>true</send-email>
|
60
|
+
</reset-items-shipping-information>}
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_behaves_correctly
|
64
|
+
[ :google_order_number, :item_info_arr, :send_email,
|
65
|
+
:google_order_number=, :item_info_arr=, :send_email= ].each do |symbol|
|
66
|
+
assert_respond_to @command, symbol
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_xml_send_email
|
71
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_accessors
|
75
|
+
assert_equal('841171949013218', @command.google_order_number)
|
76
|
+
assert @command.send_email
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_to_xml_does_not_raise_exception
|
80
|
+
assert_nothing_raised { @command.to_xml }
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|