Skip to content

Commit 197c6a7

Browse files
committed
Testing negative amounts.
1 parent f44fdf1 commit 197c6a7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

tests/Omnipay/Common/Message/AbstractRequestTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,18 @@ public function testAmountWithEmpty()
8787
$this->assertSame(null, $this->request->getAmount());
8888
}
8989

90-
public function testAmountZero()
90+
public function testAmountZeroFloat()
9191
{
9292
$this->assertSame($this->request, $this->request->setAmount(0.0));
9393
$this->assertSame('0.00', $this->request->getAmount());
9494
}
9595

96+
public function testAmountZeroString()
97+
{
98+
$this->assertSame($this->request, $this->request->setAmount('0.0'));
99+
$this->assertSame('0.00', $this->request->getAmount());
100+
}
101+
96102
public function testGetAmountNoDecimals()
97103
{
98104
$this->assertSame($this->request, $this->request->setCurrency('JPY'));
@@ -163,6 +169,24 @@ public function testAmountInvalidFormatThrowsException()
163169
$this->request->getAmount();
164170
}
165171

172+
/**
173+
* @expectedException Omnipay\Common\Exception\InvalidRequestException
174+
*/
175+
public function testAmountNegativeStringThrowsException()
176+
{
177+
$this->assertSame($this->request, $this->request->setAmount('-123.00'));
178+
$this->request->getAmount();
179+
}
180+
181+
/**
182+
* @expectedException Omnipay\Common\Exception\InvalidRequestException
183+
*/
184+
public function testAmountNegativeFloatThrowsException()
185+
{
186+
$this->assertSame($this->request, $this->request->setAmount(-123.00));
187+
$this->request->getAmount();
188+
}
189+
166190
public function testCurrency()
167191
{
168192
$this->assertSame($this->request, $this->request->setCurrency('USD'));

0 commit comments

Comments
 (0)