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,207 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/authorization_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 AuthorizationAmountNotification
|
35
|
+
class Google4R::Checkout::AuthorizationAmountNotificationTest < 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
|
+
<authorization-amount-notification xmlns="http://checkout.google.com/schema/2"
|
45
|
+
serial-number="bea6bc1b-e1e2-44fe-80ff-2391b25c2510">
|
46
|
+
<google-order-number>841171949013218</google-order-number>
|
47
|
+
<authorization-amount currency="GBP">226.06</authorization-amount>
|
48
|
+
<authorization-expiration-date>2006-03-18T20:25:31</authorization-expiration-date>
|
49
|
+
<avs-response>Y</avs-response>
|
50
|
+
<cvn-response>Y</cvn-response>
|
51
|
+
<timestamp>2006-03-18T20:25:31</timestamp>
|
52
|
+
</authorization-amount-notification>
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_create_from_element_works_correctly
|
57
|
+
root = REXML::Document.new(@example_xml).root
|
58
|
+
|
59
|
+
notification = AuthorizationAmountNotification.create_from_element(root, @frontend)
|
60
|
+
|
61
|
+
assert_equal 'bea6bc1b-e1e2-44fe-80ff-2391b25c2510', notification.serial_number
|
62
|
+
assert_equal '841171949013218', notification.google_order_number
|
63
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.timestamp
|
64
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.authorization_expiration_date
|
65
|
+
assert_equal(Money.new(22606, 'GBP'), notification.authorization_amount)
|
66
|
+
assert_equal 'Y', notification.avs_response
|
67
|
+
assert_equal 'Y', notification.cvn_response
|
68
|
+
end
|
69
|
+
end
|
70
|
+
#--
|
71
|
+
# Project: google_checkout4r
|
72
|
+
# File: test/unit/authorization_amount_notification_test.rb
|
73
|
+
# Author: Tony Chan <api.htchan AT gmail.com>
|
74
|
+
# Copyright: (c) 2007 by Tony Chan
|
75
|
+
# License: MIT License as follows:
|
76
|
+
#
|
77
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
78
|
+
# a copy of this software and associated documentation files (the
|
79
|
+
# "Software"), to deal in the Software without restriction, including
|
80
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
81
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
82
|
+
# persons to whom the Software is furnished to do so, subject to the
|
83
|
+
# following conditions:
|
84
|
+
#
|
85
|
+
# The above copyright notice and this permission notice shall be included
|
86
|
+
# in all copies or substantial portions of the Software.
|
87
|
+
#
|
88
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
89
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
90
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
91
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
92
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
93
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
94
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
95
|
+
#++
|
96
|
+
|
97
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
98
|
+
|
99
|
+
require 'google4r/checkout'
|
100
|
+
require 'rexml/document'
|
101
|
+
require 'test/frontend_configuration'
|
102
|
+
|
103
|
+
# Test for the class AuthorizationAmountNotification
|
104
|
+
class Google4R::Checkout::AuthorizationAmountNotificationTest < Test::Unit::TestCase
|
105
|
+
include Google4R::Checkout
|
106
|
+
|
107
|
+
def setup
|
108
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
109
|
+
@frontend.tax_table_factory = TestTaxTableFactory.new
|
110
|
+
|
111
|
+
@example_xml = %q{
|
112
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
113
|
+
<authorization-amount-notification xmlns="http://checkout.google.com/schema/2"
|
114
|
+
serial-number="bea6bc1b-e1e2-44fe-80ff-2391b25c2510">
|
115
|
+
<google-order-number>841171949013218</google-order-number>
|
116
|
+
<authorization-amount currency="GBP">226.06</authorization-amount>
|
117
|
+
<authorization-expiration-date>2006-03-18T20:25:31</authorization-expiration-date>
|
118
|
+
<avs-response>Y</avs-response>
|
119
|
+
<cvn-response>Y</cvn-response>
|
120
|
+
<timestamp>2006-03-18T20:25:31</timestamp>
|
121
|
+
</authorization-amount-notification>
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_create_from_element_works_correctly
|
126
|
+
root = REXML::Document.new(@example_xml).root
|
127
|
+
|
128
|
+
notification = AuthorizationAmountNotification.create_from_element(root, @frontend)
|
129
|
+
|
130
|
+
assert_equal 'bea6bc1b-e1e2-44fe-80ff-2391b25c2510', notification.serial_number
|
131
|
+
assert_equal '841171949013218', notification.google_order_number
|
132
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.timestamp
|
133
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.authorization_expiration_date
|
134
|
+
assert_equal(Money.new(22606, 'GBP'), notification.authorization_amount)
|
135
|
+
assert_equal 'Y', notification.avs_response
|
136
|
+
assert_equal 'Y', notification.cvn_response
|
137
|
+
end
|
138
|
+
end
|
139
|
+
#--
|
140
|
+
# Project: google_checkout4r
|
141
|
+
# File: test/unit/authorization_amount_notification_test.rb
|
142
|
+
# Author: Tony Chan <api.htchan AT gmail.com>
|
143
|
+
# Copyright: (c) 2007 by Tony Chan
|
144
|
+
# License: MIT License as follows:
|
145
|
+
#
|
146
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
147
|
+
# a copy of this software and associated documentation files (the
|
148
|
+
# "Software"), to deal in the Software without restriction, including
|
149
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
150
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
151
|
+
# persons to whom the Software is furnished to do so, subject to the
|
152
|
+
# following conditions:
|
153
|
+
#
|
154
|
+
# The above copyright notice and this permission notice shall be included
|
155
|
+
# in all copies or substantial portions of the Software.
|
156
|
+
#
|
157
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
158
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
159
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
160
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
161
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
162
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
163
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
164
|
+
#++
|
165
|
+
|
166
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
167
|
+
|
168
|
+
require 'google4r/checkout'
|
169
|
+
require 'rexml/document'
|
170
|
+
require 'test/frontend_configuration'
|
171
|
+
|
172
|
+
# Test for the class AuthorizationAmountNotification
|
173
|
+
class Google4R::Checkout::AuthorizationAmountNotificationTest < Test::Unit::TestCase
|
174
|
+
include Google4R::Checkout
|
175
|
+
|
176
|
+
def setup
|
177
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
178
|
+
@frontend.tax_table_factory = TestTaxTableFactory.new
|
179
|
+
|
180
|
+
@example_xml = %q{
|
181
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
182
|
+
<authorization-amount-notification xmlns="http://checkout.google.com/schema/2"
|
183
|
+
serial-number="bea6bc1b-e1e2-44fe-80ff-2391b25c2510">
|
184
|
+
<google-order-number>841171949013218</google-order-number>
|
185
|
+
<authorization-amount currency="GBP">226.06</authorization-amount>
|
186
|
+
<authorization-expiration-date>2006-03-18T20:25:31</authorization-expiration-date>
|
187
|
+
<avs-response>Y</avs-response>
|
188
|
+
<cvn-response>Y</cvn-response>
|
189
|
+
<timestamp>2006-03-18T20:25:31</timestamp>
|
190
|
+
</authorization-amount-notification>
|
191
|
+
}
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_create_from_element_works_correctly
|
195
|
+
root = REXML::Document.new(@example_xml).root
|
196
|
+
|
197
|
+
notification = AuthorizationAmountNotification.create_from_element(root, @frontend)
|
198
|
+
|
199
|
+
assert_equal 'bea6bc1b-e1e2-44fe-80ff-2391b25c2510', notification.serial_number
|
200
|
+
assert_equal '841171949013218', notification.google_order_number
|
201
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.timestamp
|
202
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.authorization_expiration_date
|
203
|
+
assert_equal(Money.new(22606, 'GBP'), notification.authorization_amount)
|
204
|
+
assert_equal 'Y', notification.avs_response
|
205
|
+
assert_equal 'Y', notification.cvn_response
|
206
|
+
end
|
207
|
+
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/authorize_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 AuthorizeOrderCommand class.
|
35
|
+
class Google4R::Checkout::AuthorizeOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_authorize_order_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
|
44
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
+
<authorize-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/authorize_order_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 AuthorizeOrderCommand class.
|
101
|
+
class Google4R::Checkout::AuthorizeOrderCommandTest < Test::Unit::TestCase
|
102
|
+
include Google4R::Checkout
|
103
|
+
|
104
|
+
def setup
|
105
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
106
|
+
@command = @frontend.create_authorize_order_command
|
107
|
+
|
108
|
+
@command.google_order_number = '841171949013218'
|
109
|
+
|
110
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
111
|
+
<authorize-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/authorize_order_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 AuthorizeOrderCommand class.
|
167
|
+
class Google4R::Checkout::AuthorizeOrderCommandTest < Test::Unit::TestCase
|
168
|
+
include Google4R::Checkout
|
169
|
+
|
170
|
+
def setup
|
171
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
172
|
+
@command = @frontend.create_authorize_order_command
|
173
|
+
|
174
|
+
@command.google_order_number = '841171949013218'
|
175
|
+
|
176
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
177
|
+
<authorize-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
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/cancel_order_command_test.rb
|
4
|
+
# Author: Dan Dukeson <dandukeson 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 CancelOrderCommand class.
|
35
|
+
class Google4R::Checkout::CancelOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_cancel_order_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.reason = 'Buyer cancelled the order'
|
44
|
+
@command.comment = 'Buyer ordered another item'
|
45
|
+
|
46
|
+
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
+
<cancel-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
+
<reason>Buyer cancelled the order</reason>
|
49
|
+
<comment>Buyer ordered another item</comment>
|
50
|
+
</cancel-order>}
|
51
|
+
|
52
|
+
@sample_xml_no_comment=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
53
|
+
<cancel-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
54
|
+
<reason>Buyer cancelled the order</reason>
|
55
|
+
</cancel-order>}
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_behaves_correctly
|
59
|
+
[ :google_order_number, :reason, :comment ].each do |symbol|
|
60
|
+
assert_respond_to @command, symbol
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_accessors
|
65
|
+
assert_equal 'Buyer cancelled the order', @command.reason
|
66
|
+
assert_equal '841171949013218', @command.google_order_number
|
67
|
+
assert_equal 'Buyer ordered another item', @command.comment
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_xml
|
71
|
+
assert_strings_equal @sample_xml, @command.to_xml
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_xml_when_comment_not_used
|
75
|
+
@command.comment = nil
|
76
|
+
assert_strings_equal @sample_xml_no_comment, @command.to_xml
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_to_xml_does_not_raise_exception
|
80
|
+
assert_nothing_raised { @command.to_xml }
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|