google4r-checkout 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +16 -2
- data/README +1 -19
- data/lib/google4r/checkout/commands.rb +208 -23
- data/lib/google4r/checkout/frontend.rb +62 -2
- data/lib/google4r/checkout/notifications.rb +302 -11
- data/lib/google4r/checkout/shared.rb +3 -3
- data/lib/google4r/checkout/xml_generation.rb +429 -225
- data/test/unit/add_merchant_order_number_command_test.rb +210 -0
- data/test/unit/add_tracking_data_command_test.rb +225 -0
- data/test/unit/archive_order_command_test.rb +198 -0
- data/test/unit/authorization_amount_notification_test.rb +207 -0
- data/test/unit/authorize_order_command_test.rb +198 -0
- data/test/unit/cancel_order_command_test.rb +83 -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 +195 -0
- data/test/unit/checkout_command_xml_generator_test.rb +12 -4
- data/test/unit/deliver_order_command_test.rb +70 -0
- data/test/unit/frontend_test.rb +14 -1
- data/test/unit/notification_handler_test.rb +28 -8
- data/test/unit/order_state_change_notification_test.rb +1 -2
- data/test/unit/refund_amount_notification_test.rb +195 -0
- data/test/unit/refund_order_command_test.rb +258 -0
- data/test/unit/risk_information_notification_test.rb +98 -0
- data/test/unit/send_buyer_message_command_test.rb +219 -0
- data/test/unit/unarchive_order_command_test.rb +198 -0
- metadata +17 -2
@@ -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,219 @@
|
|
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
|
74
|
+
#--
|
75
|
+
# Project: google_checkout4r
|
76
|
+
# File: test/unit/send_buyer_message_command_test.rb
|
77
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
78
|
+
# Copyright: (c) 2007 by Tony Chan
|
79
|
+
# License: MIT License as follows:
|
80
|
+
#
|
81
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
82
|
+
# a copy of this software and associated documentation files (the
|
83
|
+
# "Software"), to deal in the Software without restriction, including
|
84
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
85
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
86
|
+
# persons to whom the Software is furnished to do so, subject to the
|
87
|
+
# following conditions:
|
88
|
+
#
|
89
|
+
# The above copyright notice and this permission notice shall be included
|
90
|
+
# in all copies or substantial portions of the Software.
|
91
|
+
#
|
92
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
93
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
94
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
95
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
96
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
97
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
98
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
99
|
+
#++
|
100
|
+
|
101
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
102
|
+
|
103
|
+
require 'google4r/checkout'
|
104
|
+
|
105
|
+
require 'test/frontend_configuration'
|
106
|
+
|
107
|
+
# Tests for the SendBuyerMessageCommand class.
|
108
|
+
class Google4R::Checkout::SendBuyerMessageCommandTest < Test::Unit::TestCase
|
109
|
+
include Google4R::Checkout
|
110
|
+
|
111
|
+
def setup
|
112
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
113
|
+
@command = @frontend.create_send_buyer_message_command
|
114
|
+
|
115
|
+
@command.google_order_number = '841171949013218'
|
116
|
+
@command.message = 'Due to high volume, your order will ship next week. Thank you for your patience.'
|
117
|
+
@command.send_email = true
|
118
|
+
|
119
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
120
|
+
<send-buyer-message xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
121
|
+
<message>Due to high volume, your order will ship next week. Thank you for your patience.</message>
|
122
|
+
<send-email>true</send-email>
|
123
|
+
</send-buyer-message>}
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_behaves_correctly
|
127
|
+
[ :google_order_number, :message, :send_email ].each do |symbol|
|
128
|
+
assert_respond_to @command, symbol
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_xml_send_email
|
133
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_accessors
|
137
|
+
assert_equal('841171949013218', @command.google_order_number)
|
138
|
+
assert_equal('Due to high volume, your order will ship next week. Thank you for your patience.', @command.message)
|
139
|
+
assert @command.send_email
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_to_xml_does_not_raise_exception
|
143
|
+
assert_nothing_raised { @command.to_xml }
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
#--
|
148
|
+
# Project: google_checkout4r
|
149
|
+
# File: test/unit/send_buyer_message_command_test.rb
|
150
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
151
|
+
# Copyright: (c) 2007 by Tony Chan
|
152
|
+
# License: MIT License as follows:
|
153
|
+
#
|
154
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
155
|
+
# a copy of this software and associated documentation files (the
|
156
|
+
# "Software"), to deal in the Software without restriction, including
|
157
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
158
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
159
|
+
# persons to whom the Software is furnished to do so, subject to the
|
160
|
+
# following conditions:
|
161
|
+
#
|
162
|
+
# The above copyright notice and this permission notice shall be included
|
163
|
+
# in all copies or substantial portions of the Software.
|
164
|
+
#
|
165
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
166
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
167
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
168
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
169
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
170
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
171
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
172
|
+
#++
|
173
|
+
|
174
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
175
|
+
|
176
|
+
require 'google4r/checkout'
|
177
|
+
|
178
|
+
require 'test/frontend_configuration'
|
179
|
+
|
180
|
+
# Tests for the SendBuyerMessageCommand class.
|
181
|
+
class Google4R::Checkout::SendBuyerMessageCommandTest < Test::Unit::TestCase
|
182
|
+
include Google4R::Checkout
|
183
|
+
|
184
|
+
def setup
|
185
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
186
|
+
@command = @frontend.create_send_buyer_message_command
|
187
|
+
|
188
|
+
@command.google_order_number = '841171949013218'
|
189
|
+
@command.message = 'Due to high volume, your order will ship next week. Thank you for your patience.'
|
190
|
+
@command.send_email = true
|
191
|
+
|
192
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
193
|
+
<send-buyer-message xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
194
|
+
<message>Due to high volume, your order will ship next week. Thank you for your patience.</message>
|
195
|
+
<send-email>true</send-email>
|
196
|
+
</send-buyer-message>}
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_behaves_correctly
|
200
|
+
[ :google_order_number, :message, :send_email ].each do |symbol|
|
201
|
+
assert_respond_to @command, symbol
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_xml_send_email
|
206
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
207
|
+
end
|
208
|
+
|
209
|
+
def test_accessors
|
210
|
+
assert_equal('841171949013218', @command.google_order_number)
|
211
|
+
assert_equal('Due to high volume, your order will ship next week. Thank you for your patience.', @command.message)
|
212
|
+
assert @command.send_email
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_to_xml_does_not_raise_exception
|
216
|
+
assert_nothing_raised { @command.to_xml }
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
@@ -0,0 +1,198 @@
|
|
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
|
67
|
+
#--
|
68
|
+
# Project: google_checkout4r
|
69
|
+
# File: test/unit/unarchive_command_test.rb
|
70
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
71
|
+
# Copyright: (c) 2007 by Tony Chan
|
72
|
+
# License: MIT License as follows:
|
73
|
+
#
|
74
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
75
|
+
# a copy of this software and associated documentation files (the
|
76
|
+
# "Software"), to deal in the Software without restriction, including
|
77
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
78
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
79
|
+
# persons to whom the Software is furnished to do so, subject to the
|
80
|
+
# following conditions:
|
81
|
+
#
|
82
|
+
# The above copyright notice and this permission notice shall be included
|
83
|
+
# in all copies or substantial portions of the Software.
|
84
|
+
#
|
85
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
86
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
87
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
88
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
89
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
90
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
91
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
92
|
+
#++
|
93
|
+
|
94
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
95
|
+
|
96
|
+
require 'google4r/checkout'
|
97
|
+
|
98
|
+
require 'test/frontend_configuration'
|
99
|
+
|
100
|
+
# Tests for the UnarchiveOrderCommand class.
|
101
|
+
class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
102
|
+
include Google4R::Checkout
|
103
|
+
|
104
|
+
def setup
|
105
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
106
|
+
@command = @frontend.create_unarchive_order_command
|
107
|
+
|
108
|
+
@command.google_order_number = '841171949013218'
|
109
|
+
|
110
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
111
|
+
<unarchive-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_behaves_correctly
|
115
|
+
[ :google_order_number ].each do |symbol|
|
116
|
+
assert_respond_to @command, symbol
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_xml
|
121
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_accessors
|
125
|
+
assert_equal('841171949013218', @command.google_order_number)
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_to_xml_does_not_raise_exception
|
129
|
+
assert_nothing_raised { @command.to_xml }
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
#--
|
134
|
+
# Project: google_checkout4r
|
135
|
+
# File: test/unit/unarchive_command_test.rb
|
136
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
137
|
+
# Copyright: (c) 2007 by Tony Chan
|
138
|
+
# License: MIT License as follows:
|
139
|
+
#
|
140
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
141
|
+
# a copy of this software and associated documentation files (the
|
142
|
+
# "Software"), to deal in the Software without restriction, including
|
143
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
144
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
145
|
+
# persons to whom the Software is furnished to do so, subject to the
|
146
|
+
# following conditions:
|
147
|
+
#
|
148
|
+
# The above copyright notice and this permission notice shall be included
|
149
|
+
# in all copies or substantial portions of the Software.
|
150
|
+
#
|
151
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
152
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
153
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
154
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
155
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
156
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
157
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
158
|
+
#++
|
159
|
+
|
160
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
161
|
+
|
162
|
+
require 'google4r/checkout'
|
163
|
+
|
164
|
+
require 'test/frontend_configuration'
|
165
|
+
|
166
|
+
# Tests for the UnarchiveOrderCommand class.
|
167
|
+
class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
168
|
+
include Google4R::Checkout
|
169
|
+
|
170
|
+
def setup
|
171
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
172
|
+
@command = @frontend.create_unarchive_order_command
|
173
|
+
|
174
|
+
@command.google_order_number = '841171949013218'
|
175
|
+
|
176
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
177
|
+
<unarchive-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_behaves_correctly
|
181
|
+
[ :google_order_number ].each do |symbol|
|
182
|
+
assert_respond_to @command, symbol
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_xml
|
187
|
+
assert_strings_equal(@sample_xml, @command.to_xml)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_accessors
|
191
|
+
assert_equal('841171949013218', @command.google_order_number)
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_to_xml_does_not_raise_exception
|
195
|
+
assert_nothing_raised { @command.to_xml }
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|