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,146 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_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
|
+
# Tests for the ShoppingCart class and all subclasses.
|
35
|
+
class Google4R::Checkout::ShoppingCartTest < 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
|
+
@command = @frontend.create_checkout_command
|
42
|
+
@shopping_cart = @command.shopping_cart
|
43
|
+
|
44
|
+
@xml_str = %q{<?xml version="1.0" encoding="UTF-8" ?>
|
45
|
+
<shopping-cart>
|
46
|
+
<merchant-private-data>
|
47
|
+
<affiliate-code>01234</affiliate-code>
|
48
|
+
</merchant-private-data>
|
49
|
+
<cart-expiration>
|
50
|
+
<good-until-date>2007-12-31T23:59:59-05:00</good-until-date>
|
51
|
+
</cart-expiration>
|
52
|
+
<items>
|
53
|
+
<item>
|
54
|
+
<item-name>AA Rechargeable Battery Pack</item-name>
|
55
|
+
<item-description>Battery pack containing four AA rechargeable batteries</item-description>
|
56
|
+
<unit-price currency="USD">12.00</unit-price>
|
57
|
+
<quantity>1</quantity>
|
58
|
+
</item>
|
59
|
+
<item>
|
60
|
+
<item-name>MegaSound 2GB MP3 Player</item-name>
|
61
|
+
<item-description>Portable MP3 player - stores 500 songs</item-description>
|
62
|
+
<quantity>1</quantity>
|
63
|
+
<unit-price currency="USD">178.00</unit-price>
|
64
|
+
</item>
|
65
|
+
</items>
|
66
|
+
</shopping-cart>}
|
67
|
+
|
68
|
+
@optional_tags = [ 'cart-expiration', 'merchant-private-data' ]
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_behaves_correctly
|
72
|
+
[ :owner, :expires_at, :items, :owner, :private_data, :private_data= ].each do |sym|
|
73
|
+
assert_respond_to @shopping_cart, sym
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_initialized_correctly
|
78
|
+
assert_equal @command, @shopping_cart.owner
|
79
|
+
assert_equal nil, @shopping_cart.expires_at
|
80
|
+
assert_equal [], @shopping_cart.items
|
81
|
+
assert_equal @command, @shopping_cart.owner
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_accessors_work_correctly
|
85
|
+
hash = { 'foo' => [ { 'bar' => 'baz' }, "d'oh", 2 ] }
|
86
|
+
@shopping_cart.private_data = hash.dup
|
87
|
+
assert_equal hash, @shopping_cart.private_data
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_setting_private_data_only_works_with_a_hash
|
91
|
+
assert_raises(RuntimeError) { @shopping_cart.private_data = 1 }
|
92
|
+
assert_raises(RuntimeError) { @shopping_cart.private_data = nil }
|
93
|
+
assert_raises(RuntimeError) { @shopping_cart.private_data = 'Foobar' }
|
94
|
+
assert_raises(RuntimeError) { @shopping_cart.private_data = [] }
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_create_item_works_correctly_with_block
|
98
|
+
the_item = nil
|
99
|
+
|
100
|
+
res =
|
101
|
+
@shopping_cart.create_item do |item|
|
102
|
+
the_item = item
|
103
|
+
|
104
|
+
assert_kind_of Item, item
|
105
|
+
end
|
106
|
+
|
107
|
+
assert_equal res, the_item
|
108
|
+
assert @shopping_cart.items.include?(the_item)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_create_item_works_correctly_without_block
|
112
|
+
item = @shopping_cart.create_item
|
113
|
+
|
114
|
+
assert @shopping_cart.items.include?(item)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_create_from_element_works
|
118
|
+
@optional_tags.power.each do |optional_tag_names|
|
119
|
+
xml_str = @xml_str
|
120
|
+
|
121
|
+
optional_tag_names.each { |name| xml_str = xml_str.gsub(%r{<#{name}.*?</#{name}>}, '') }
|
122
|
+
|
123
|
+
element = REXML::Document.new(xml_str).root
|
124
|
+
|
125
|
+
expect = Item.stubs(:create_from_element)
|
126
|
+
expect.with do |element, shopping_cart|
|
127
|
+
element.name == 'item' and
|
128
|
+
element.elements['item-name'].text == 'AA Rechargeable Battery Pack'
|
129
|
+
end
|
130
|
+
expect.times(1).returns(:item1)
|
131
|
+
|
132
|
+
expect = Item.stubs(:create_from_element)
|
133
|
+
expect.with do |element, shopping_cart|
|
134
|
+
element.name == 'item' and
|
135
|
+
element.elements['item-name'].text == 'MegaSound 2GB MP3 Player'
|
136
|
+
end
|
137
|
+
expect.times(1).returns(:item2)
|
138
|
+
|
139
|
+
shopping_cart = ShoppingCart.create_from_element(element, nil)
|
140
|
+
|
141
|
+
assert_equal Time.parse("2007-12-31T23:59:59-05:00"), shopping_cart.expires_at unless optional_tag_names.include?('cart-expiration')
|
142
|
+
assert_equal [ :item1, :item2 ], shopping_cart.items
|
143
|
+
assert_equal({ 'affiliate-code' => '01234' }, shopping_cart.private_data) unless optional_tag_names.include?('merchant-private-data')
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_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
|
+
# Tests for the TaxRule class.
|
35
|
+
class Google4R::Checkout::TaxRuleTest < 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
|
+
@command = @frontend.create_checkout_command
|
42
|
+
@table = TaxTable.new(false)
|
43
|
+
@rule = @table.create_rule
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_tax_rule_gets_initialized_correctly
|
47
|
+
assert_equal @table, @rule.table
|
48
|
+
assert_nil @rule.area
|
49
|
+
assert_nil @rule.rate
|
50
|
+
assert !@rule.shipping_taxed
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_tax_rule_behaves_correctly
|
54
|
+
assert_respond_to @rule, :table
|
55
|
+
assert_respond_to @rule, :area
|
56
|
+
assert_respond_to @rule, :rate
|
57
|
+
assert_respond_to @rule, :shipping_taxed
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_tax_rule_accessors_work
|
61
|
+
@rule.area = :area
|
62
|
+
assert_equal :area, @rule.area
|
63
|
+
|
64
|
+
@rule.rate = 0.5
|
65
|
+
assert_equal 0.5, @rule.rate
|
66
|
+
|
67
|
+
@rule.shipping_taxed=true
|
68
|
+
assert @rule.shipping_taxed
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_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 TaxTable class.
|
35
|
+
class Google4R::Checkout::TaxTableTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@table = TaxTable.new(false)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_table_behaves_correctly
|
43
|
+
assert_respond_to @table, :rules
|
44
|
+
assert_respond_to @table, :name
|
45
|
+
assert_respond_to @table, :name=
|
46
|
+
assert_respond_to @table, :standalone
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_initialized_correctly
|
50
|
+
assert_nil @table.name
|
51
|
+
assert_equal [], @table.rules
|
52
|
+
assert_equal false, @table.standalone
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_accessors_work_correctly
|
56
|
+
@table.name = "name"
|
57
|
+
assert_equal "name", @table.name
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_create_rule_works_correctly_with_block
|
61
|
+
the_rule = nil
|
62
|
+
|
63
|
+
res =
|
64
|
+
@table.create_rule do |rule|
|
65
|
+
the_rule = rule
|
66
|
+
assert_kind_of TaxRule, rule
|
67
|
+
end
|
68
|
+
|
69
|
+
assert_equal res, the_rule
|
70
|
+
assert @table.rules.include?(the_rule)
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_create_rule_works_correctly_without_block
|
74
|
+
res = nil
|
75
|
+
|
76
|
+
res = @table.create_rule
|
77
|
+
|
78
|
+
assert_kind_of TaxRule, res
|
79
|
+
|
80
|
+
assert @table.rules.include?(res)
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'google4r/checkout'
|
2
|
+
|
3
|
+
require 'test/frontend_configuration'
|
4
|
+
#--
|
5
|
+
# Project: google_checkout4r
|
6
|
+
# File: test/unit/tracking_data_test.rb
|
7
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
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 TrackingData.
|
38
|
+
class Google4R::Checkout::TrackingDataTest < Test::Unit::TestCase
|
39
|
+
include Google4R::Checkout
|
40
|
+
|
41
|
+
def setup
|
42
|
+
@tracking_data = TrackingData.new('UPS', '1234')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_initialization_works
|
46
|
+
assert_kind_of TrackingData, @tracking_data
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_responds_correctly
|
50
|
+
[ :carrier, :tracking_number].each do |sym|
|
51
|
+
assert_respond_to @tracking_data, sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/unarchive_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 UnarchiveOrderCommand class.
|
35
|
+
class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_unarchive_order_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
|
44
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
+
<unarchive-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_behaves_correctly
|
49
|
+
[ :google_order_number ].each do |symbol|
|
50
|
+
assert_respond_to @command, symbol
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_xml
|
55
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_accessors
|
59
|
+
assert_equal('841171949013218', @command.google_order_number)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_to_xml_does_not_raise_exception
|
63
|
+
assert_nothing_raised { @command.to_xml }
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/us_country_area_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 UsCountryArea.
|
35
|
+
class Google4R::Checkout::UsCountryAreaTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@area = UsCountryArea.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_constants_are_defined
|
43
|
+
assert defined?(UsCountryArea::CONTINENTAL_48)
|
44
|
+
assert defined?(UsCountryArea::FULL_50_STATES)
|
45
|
+
assert defined?(UsCountryArea::ALL)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_initialization
|
49
|
+
assert_nil @area.area
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_creator_sets_area
|
53
|
+
area = UsCountryArea.new(UsCountryArea::ALL)
|
54
|
+
assert_equal UsCountryArea::ALL, area.area
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def test_us_country_area_behaves_correctly
|
59
|
+
assert_respond_to @area, :area
|
60
|
+
assert_respond_to @area, :area=
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_us_country_area_area_accessor_works
|
64
|
+
assert_nil @area.area
|
65
|
+
|
66
|
+
[ UsCountryArea::CONTINENTAL_48, UsCountryArea::FULL_50_STATES, UsCountryArea::ALL ].each do |str|
|
67
|
+
@area.area = str
|
68
|
+
assert_equal str, @area.area
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_us_country_area_area_validation_works
|
73
|
+
assert_raises(RuntimeError) { @area.area = 'invalid value' }
|
74
|
+
assert_nil @area.area
|
75
|
+
end
|
76
|
+
end
|