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,83 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/return_items_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 ReturnItemsCommand class.
|
35
|
+
class Google4R::Checkout::ReturnItemsCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_return_items_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
|
+
<return-items 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
|
+
</return-items>}
|
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
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/risk_info_notification_test.rb
|
4
|
+
# Author: Dan Dukeson <dandukeson AT gmail.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
|
+
require 'rexml/document'
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class Area.
|
35
|
+
class Google4R::Checkout::RiskInformationNotificationTest < 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
|
+
<risk-information-notification xmlns="http://checkout.google.com/schema/2" serial-number="4f5adc5b-aac5-4618-9e3b-75e60eaf29cd">
|
45
|
+
<timestamp>2007-04-30T08:03:57.000Z</timestamp>
|
46
|
+
<google-order-number>1564645586934214</google-order-number>
|
47
|
+
<risk-information>
|
48
|
+
<billing-address>
|
49
|
+
<!-- Not to be tested here but in Address --
|
50
|
+
<!--
|
51
|
+
<contact-name>Mr Contact Smith</contact-name>
|
52
|
+
<company-name>ACME Products</company-name>
|
53
|
+
<email>contact_smith@example.com</email>
|
54
|
+
<phone>012345 234567</phone>
|
55
|
+
<fax>012345 345678</fax>
|
56
|
+
<address1>123 Testing Road</address1>
|
57
|
+
<address2>Test Village</address2>
|
58
|
+
<country-code>GB</country-code>
|
59
|
+
<city>Testcity</city>
|
60
|
+
<region>South Testshire</region>
|
61
|
+
<postal-code>S6 1TT</postal-code>
|
62
|
+
-->
|
63
|
+
</billing-address>
|
64
|
+
<ip-address>123.456.123.456</ip-address>
|
65
|
+
<avs-response>Y</avs-response>
|
66
|
+
<cvn-response>M</cvn-response>
|
67
|
+
<eligible-for-protection>true</eligible-for-protection>
|
68
|
+
<partial-cc-number>6789</partial-cc-number>
|
69
|
+
<buyer-account-age>61</buyer-account-age>
|
70
|
+
</risk-information>
|
71
|
+
</risk-information-notification>
|
72
|
+
}
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_create_from_element_works_correctly
|
77
|
+
# Stub out Address creation.
|
78
|
+
expectation = Address.stubs(:create_from_element).times(1).returns(:address)
|
79
|
+
expectation.with { |param| param.name == 'billing-address' }
|
80
|
+
|
81
|
+
root = REXML::Document.new(@example_xml).root
|
82
|
+
|
83
|
+
notification = RiskInformationNotification.create_from_element(root, @frontend)
|
84
|
+
|
85
|
+
assert_equal '4f5adc5b-aac5-4618-9e3b-75e60eaf29cd', notification.serial_number
|
86
|
+
assert_equal '1564645586934214', notification.google_order_number
|
87
|
+
assert_equal true, notification.eligible_for_protection
|
88
|
+
|
89
|
+
assert_equal :address, notification.buyer_billing_address
|
90
|
+
|
91
|
+
assert_equal 'Y', notification.avs_response
|
92
|
+
assert_equal 'M', notification.cvn_response
|
93
|
+
assert_equal '6789', notification.partial_card_number
|
94
|
+
assert_equal '123.456.123.456', notification.ip_address
|
95
|
+
assert_equal 61, notification.buyer_account_age
|
96
|
+
assert_equal Time.parse('2007-04-30T08:03:57.000Z'), notification.timestamp
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/send_buyer_message_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 SendBuyerMessageCommand class.
|
35
|
+
class Google4R::Checkout::SendBuyerMessageCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_send_buyer_message_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.message = 'Due to high volume, your order will ship next week. Thank you for your patience.'
|
44
|
+
@command.send_email = true
|
45
|
+
|
46
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
+
<send-buyer-message xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
+
<message>Due to high volume, your order will ship next week. Thank you for your patience.</message>
|
49
|
+
<send-email>true</send-email>
|
50
|
+
</send-buyer-message>}
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_behaves_correctly
|
54
|
+
[ :google_order_number, :message, :send_email ].each do |symbol|
|
55
|
+
assert_respond_to @command, symbol
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_xml_send_email
|
60
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_accessors
|
64
|
+
assert_equal('841171949013218', @command.google_order_number)
|
65
|
+
assert_equal('Due to high volume, your order will ship next week. Thank you for your patience.', @command.message)
|
66
|
+
assert @command.send_email
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_to_xml_does_not_raise_exception
|
70
|
+
assert_nothing_raised { @command.to_xml }
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/ship_items_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 ShipItemsCommand class.
|
35
|
+
class Google4R::Checkout::ShipItemsCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_ship_items_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.send_email = true
|
44
|
+
@item_info_1 = ItemInfo.new('A1')
|
45
|
+
@item_info_1.create_tracking_data('UPS', 55555555)
|
46
|
+
@item_info_2 = ItemInfo.new('A2')
|
47
|
+
@item_info_2.create_tracking_data('FedEx', 12345678)
|
48
|
+
@command.item_info_arr = [@item_info_1, @item_info_2]
|
49
|
+
|
50
|
+
|
51
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
52
|
+
<ship-items xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
53
|
+
<item-shipping-information-list>
|
54
|
+
<item-shipping-information>
|
55
|
+
<item-id>
|
56
|
+
<merchant-item-id>A1</merchant-item-id>
|
57
|
+
</item-id>
|
58
|
+
<tracking-data-list>
|
59
|
+
<tracking-data>
|
60
|
+
<carrier>UPS</carrier>
|
61
|
+
<tracking-number>55555555</tracking-number>
|
62
|
+
</tracking-data>
|
63
|
+
</tracking-data-list>
|
64
|
+
</item-shipping-information>
|
65
|
+
<item-shipping-information>
|
66
|
+
<item-id>
|
67
|
+
<merchant-item-id>A2</merchant-item-id>
|
68
|
+
</item-id>
|
69
|
+
<tracking-data-list>
|
70
|
+
<tracking-data>
|
71
|
+
<carrier>FedEx</carrier>
|
72
|
+
<tracking-number>12345678</tracking-number>
|
73
|
+
</tracking-data>
|
74
|
+
</tracking-data-list>
|
75
|
+
</item-shipping-information>
|
76
|
+
</item-shipping-information-list>
|
77
|
+
<send-email>true</send-email>
|
78
|
+
</ship-items>}
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_behaves_correctly
|
82
|
+
[ :google_order_number, :item_info_arr, :send_email,
|
83
|
+
:google_order_number=, :item_info_arr=, :send_email= ].each do |symbol|
|
84
|
+
assert_respond_to @command, symbol
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_xml_send_email
|
89
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_accessors
|
93
|
+
assert_equal('841171949013218', @command.google_order_number)
|
94
|
+
assert @command.send_email
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_to_xml_does_not_raise_exception
|
98
|
+
assert_nothing_raised { @command.to_xml }
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/shipping_adjustment_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 ShippingAdjustmentTest.
|
35
|
+
class Google4R::Checkout::ShippingAdjustmentTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@xml_str = %q{<?xml version="1.0" encoding="UTF-8" ?>
|
40
|
+
<%s>
|
41
|
+
<shipping-name>%s</shipping-name>
|
42
|
+
<shipping-cost currency="%s">%s</shipping-cost>
|
43
|
+
</%s>}
|
44
|
+
|
45
|
+
@valid_adjustment_types =
|
46
|
+
[
|
47
|
+
[ "FLAT_RATE", 'flat-rate-shipping-adjustment' ],
|
48
|
+
[ "PICKUP", 'pickup-shipping-adjustment' ],
|
49
|
+
]
|
50
|
+
|
51
|
+
@invalid_adjustment_types = [ 'merchant-calculated-shipping', 'invalid-shipping' ]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_responds_correctly
|
55
|
+
adjustment = ShippingAdjustment.new
|
56
|
+
|
57
|
+
[ :type, :type=, :name, :name=, :cost, :cost= ].each do |symbol|
|
58
|
+
assert_respond_to adjustment, symbol
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_constants_are_defined
|
63
|
+
assert defined?(ShippingAdjustment::FLAT_RATE)
|
64
|
+
assert defined?(ShippingAdjustment::PICKUP)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_create_from_element_works_with_valid_shipping_adjustment_types
|
68
|
+
@valid_adjustment_types.each do |pair|
|
69
|
+
type, tag_name = pair
|
70
|
+
|
71
|
+
xml_str = @xml_str %
|
72
|
+
[
|
73
|
+
tag_name, 'Some Name', 'USD', '10.00', tag_name
|
74
|
+
]
|
75
|
+
|
76
|
+
element = REXML::Document.new(xml_str).root
|
77
|
+
|
78
|
+
adjustment = ShippingAdjustment.create_from_element(element)
|
79
|
+
|
80
|
+
assert_equal Money.new(1000, 'USD'), adjustment.cost
|
81
|
+
assert_equal type, adjustment.type
|
82
|
+
assert_equal 'Some Name', adjustment.name
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_create_from_element_raises_exception_with_invalid_shipping_adjustment_types
|
87
|
+
@invalid_adjustment_types.each do |tag_name|
|
88
|
+
xml_str = @xml_str %
|
89
|
+
[
|
90
|
+
tag_name, 'Some Name', 'USD', '10.00', tag_name
|
91
|
+
]
|
92
|
+
|
93
|
+
element = REXML::Document.new(xml_str).root
|
94
|
+
|
95
|
+
assert_raises(RuntimeError) do
|
96
|
+
adjustment = ShippingAdjustment.create_from_element(element)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|