test/unit/gateways/data_cash_test.rb in activemerchant-1.3.2 vs test/unit/gateways/data_cash_test.rb in activemerchant-1.4.0
- old
+ new
@@ -35,11 +35,11 @@
response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response
assert response.test?
assert_equal 'The transaction was successful', response.message
- assert_equal '4400200050664928;123456789', response.authorization
+ assert_equal '4400200050664928;123456789;', response.authorization
end
def test_unsuccessful_purchase
@gateway.expects(:ssl_post).returns(failed_purchase_response)
@@ -48,11 +48,11 @@
assert_failure response
assert response.test?
assert_equal 'Invalid reference number', response.message
end
- def test_error_
+ def test_error_response
@gateway.expects(:ssl_post).returns(failed_purchase_response)
response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_failure response
@@ -66,10 +66,38 @@
def test_supported_card_types
assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
end
+ def test_purchase_with_missing_order_id_option
+ assert_raise(ArgumentError){ @gateway.purchase(100, @credit_card, {}) }
+ end
+
+ def test_authorize_with_missing_order_id_option
+ assert_raise(ArgumentError){ @gateway.authorize(100, @credit_card, {}) }
+ end
+
+ def test_purchase_does_not_raise_exception_with_missing_billing_address
+ assert @gateway.authorize(100, @credit_card, {:order_id => generate_unique_id }).is_a?(ActiveMerchant::Billing::Response)
+ end
+
+ def test_continuous_authority_purchase_with_missing_continuous_authority_reference
+ assert_raise(ArgumentError) do
+ @gateway.authorize(100, "a;b;", @options)
+ end
+ end
+
+ def test_successful_continuous_authority_purchase
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
+
+ response = @gateway.purchase(@amount, '4400200050664928;123456789;10000000', @options)
+ assert_instance_of Response, response
+ assert_success response
+ assert response.test?
+ assert_equal 'The transaction was successful', response.message
+ end
+
private
def failed_purchase_response
<<-XML
<Response>
<status>22</status>
@@ -98,7 +126,7 @@
<card_scheme>Visa</card_scheme>
<datacash_reference>4400200050664928</datacash_reference>
<authcode>123456789</authcode>
</Response>
XML
- end
-end
\ No newline at end of file
+ end
+end