|
8 | 8 |
|
9 | 9 | class DecimalInternalValidationTest extends PHPUnit_Framework_TestCase
|
10 | 10 | {
|
11 |
| - public function testInternalConstructorValidation() |
| 11 | + /** |
| 12 | + * @expectedException \InvalidArgumentException |
| 13 | + * @expectedExceptionMessage $value must be a non null number |
| 14 | + */ |
| 15 | + public function testConstructorNullValueValidation() |
12 | 16 | {
|
13 |
| - $thrown = false; |
14 |
| - try { |
15 |
| - $d = Decimal::fromInteger(null); |
16 |
| - } catch (InvalidArgumentException $e) { |
17 |
| - $thrown = true; |
18 |
| - } |
19 |
| - $this->assertTrue($thrown); |
20 |
| - |
21 |
| - $thrown = false; |
22 |
| - try { |
23 |
| - $d = Decimal::fromInteger(25, -15); |
24 |
| - } catch (InvalidArgumentException $e) { |
25 |
| - $thrown = true; |
26 |
| - } |
27 |
| - $this->assertTrue($thrown); |
28 |
| - |
29 |
| - $thrown = false; |
30 |
| - try { |
31 |
| - $d = Decimal::fromInteger(25, "hola mundo"); |
32 |
| - } catch (InvalidArgumentException $e) { |
33 |
| - $thrown = true; |
34 |
| - } |
35 |
| - $this->assertTrue($thrown); |
| 17 | + Decimal::fromInteger(null); |
36 | 18 | }
|
37 | 19 |
|
38 |
| - public function testInternalOperatorValidation() |
| 20 | + /** |
| 21 | + * @expectedException \InvalidArgumentException |
| 22 | + * @expectedExceptionMessage $scale must be a positive integer |
| 23 | + */ |
| 24 | + public function testConstructorNegativeScaleValidation() |
| 25 | + { |
| 26 | + Decimal::fromInteger(25, -15); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @expectedException \InvalidArgumentException |
| 31 | + * @expectedExceptionMessage $scale must be a positive integer |
| 32 | + */ |
| 33 | + public function testConstructorNotIntegerScaleValidation() |
| 34 | + { |
| 35 | + Decimal::fromInteger(25, "hola mundo"); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @expectedException \InvalidArgumentException |
| 40 | + * @expectedExceptionMessage $scale must be a positive integer |
| 41 | + */ |
| 42 | + public function testOperatorNegativeScaleValidation() |
39 | 43 | {
|
40 | 44 | $one = Decimal::fromInteger(1);
|
41 | 45 |
|
42 |
| - $thrown = false; |
43 |
| - try { |
44 |
| - $d = $one->mul($one, -1); |
45 |
| - } catch (InvalidArgumentException $e) { |
46 |
| - $thrown = true; |
47 |
| - } |
48 |
| - $this->assertTrue($thrown); |
| 46 | + $one->mul($one, -1); |
49 | 47 | }
|
50 | 48 | }
|
0 commit comments