@@ -87,18 +87,28 @@ public function testAmountWithEmpty()
87
87
$ this ->assertSame (null , $ this ->request ->getAmount ());
88
88
}
89
89
90
+ public function testAmountZero ()
91
+ {
92
+ $ this ->assertSame ($ this ->request , $ this ->request ->setAmount (0.0 ));
93
+ $ this ->assertSame ('0.00 ' , $ this ->request ->getAmount ());
94
+ }
95
+
90
96
public function testGetAmountNoDecimals ()
91
97
{
92
98
$ this ->assertSame ($ this ->request , $ this ->request ->setCurrency ('JPY ' ));
93
99
$ this ->assertSame ($ this ->request , $ this ->request ->setAmount ('1366 ' ));
94
100
$ this ->assertSame ('1366 ' , $ this ->request ->getAmount ());
95
101
}
96
102
103
+ /**
104
+ * @expectedException Omnipay\Common\Exception\InvalidRequestException
105
+ */
97
106
public function testGetAmountNoDecimalsRounding ()
98
107
{
108
+ // There will not be any rounding; the amount is sent as requested or not at all.
99
109
$ this ->assertSame ($ this ->request , $ this ->request ->setAmount ('136.5 ' ));
100
110
$ this ->assertSame ($ this ->request , $ this ->request ->setCurrency ('JPY ' ));
101
- $ this ->assertSame ( ' 137 ' , $ this -> request ->getAmount () );
111
+ $ this ->request ->getAmount ();
102
112
}
103
113
104
114
/**
@@ -117,6 +127,7 @@ public function testAmountWithIntThrowsException()
117
127
public function testAmountWithIntStringThrowsException ()
118
128
{
119
129
// ambiguous value, avoid errors upgrading from v0.9
130
+ // Some currencies only take integers, so an integer (in a string) should be valid.
120
131
$ this ->assertSame ($ this ->request , $ this ->request ->setAmount ('10 ' ));
121
132
$ this ->request ->getAmount ();
122
133
}
@@ -134,6 +145,24 @@ public function testGetAmountIntegerNoDecimals()
134
145
$ this ->assertSame (1366 , $ this ->request ->getAmountInteger ());
135
146
}
136
147
148
+ /**
149
+ * @expectedException Omnipay\Common\Exception\InvalidRequestException
150
+ */
151
+ public function testAmountThousandsSepThrowsException ()
152
+ {
153
+ $ this ->assertSame ($ this ->request , $ this ->request ->setAmount ('1,234.00 ' ));
154
+ $ this ->request ->getAmount ();
155
+ }
156
+
157
+ /**
158
+ * @expectedException Omnipay\Common\Exception\InvalidRequestException
159
+ */
160
+ public function testAmountInvalidFormatThrowsException ()
161
+ {
162
+ $ this ->assertSame ($ this ->request , $ this ->request ->setAmount ('1.234.00 ' ));
163
+ $ this ->request ->getAmount ();
164
+ }
165
+
137
166
public function testCurrency ()
138
167
{
139
168
$ this ->assertSame ($ this ->request , $ this ->request ->setCurrency ('USD ' ));
0 commit comments