Completed
Push — master ( b9f967...7a222d )
by Andreu
9s
created

DecimalIsZeroTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 0
cbo 2
dl 0
loc 25
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testZeros() 0 6 1
A testPositiveNumbers() 0 7 1
A testNegativeNumbers() 0 7 1
1
<?php
2
3
use Litipk\BigNumbers\Decimal as Decimal;
4
5
6
date_default_timezone_set('UTC');
7
8
9
class DecimalIsZeroTest extends PHPUnit_Framework_TestCase
10
{
11
    public function testZeros()
12
    {
13
        $this->assertTrue(Decimal::fromInteger(0)->isZero());
14
        $this->assertTrue(Decimal::fromFloat(0.0)->isZero());
15
        $this->assertTrue(Decimal::fromString('0')->isZero());
16
    }
17
18
    public function testPositiveNumbers()
19
    {
20
        $this->assertFalse(Decimal::fromInteger(1)->isZero());
21
        $this->assertFalse(Decimal::fromFloat(1.0)->isZero());
22
        $this->assertFalse(Decimal::fromFloat(0.1)->isZero());
23
        $this->assertFalse(Decimal::fromString('1')->isZero());
24
    }
25
26
    public function testNegativeNumbers()
27
    {
28
        $this->assertFalse(Decimal::fromInteger(-1)->isZero());
29
        $this->assertFalse(Decimal::fromFloat(-1.0)->isZero());
30
        $this->assertFalse(Decimal::fromFloat(-0.1)->isZero());
31
        $this->assertFalse(Decimal::fromString('-1')->isZero());
32
    }
33
}
34