Exemplo n.º 1
0
 /**
  * @test comparisonFunctions
  * @dataProvider comparisonData
  */
 public function comparisonFunctionTest($val1, $val2, $expectedResult)
 {
     $num1 = new BigDecimal($val1);
     $num2 = new BigDecimal($val2);
     $this->assertEquals($expectedResult, $num1->compareTo($num2));
     if ($expectedResult == -1) {
         $this->assertEquals(true, $num1->isLessThan($num2));
         $this->assertEquals(true, $num1->isLessThanOrEqualTo($num2));
         $this->assertEquals(false, $num1->isEqualTo($num2));
         $this->assertEquals(false, $num1->isGreaterThan($num2));
         $this->assertEquals(false, $num1->isGreaterThanOrEqualTo($num2));
     }
     if ($expectedResult == 0) {
         $this->assertEquals(false, $num1->isLessThan($num2));
         $this->assertEquals(true, $num1->isLessThanOrEqualTo($num2));
         $this->assertEquals(true, $num1->isEqualTo($num2));
         $this->assertEquals(false, $num1->isGreaterThan($num2));
         $this->assertEquals(true, $num1->isGreaterThanOrEqualTo($num2));
     }
     if ($expectedResult == 1) {
         $this->assertEquals(false, $num1->isLessThan($num2));
         $this->assertEquals(false, $num1->isLessThanOrEqualTo($num2));
         $this->assertEquals(false, $num1->isEqualTo($num2));
         $this->assertEquals(true, $num1->isGreaterThan($num2));
         $this->assertEquals(true, $num1->isGreaterThanOrEqualTo($num2));
     }
 }