コード例 #1
0
ファイル: ValidatorTest.php プロジェクト: nilamdoc/KYCGlobal
 /**
  * Test decimal validation with precision specified.
  */
 public function testDecimalWithPlaces()
 {
     $this->assertTrue(Validator::isDecimal('.27', null, array('precision' => '2')));
     $this->assertTrue(Validator::isDecimal(0.27, null, array('precision' => 2)));
     $this->assertTrue(Validator::isDecimal(-0.27, null, array('precision' => 2)));
     $this->assertTrue(Validator::isDecimal(+0.27, null, array('precision' => 2)));
     $this->assertTrue(Validator::isDecimal('.277', null, array('precision' => '3')));
     $this->assertTrue(Validator::isDecimal(0.277, null, array('precision' => 3)));
     $this->assertTrue(Validator::isDecimal(-0.277, null, array('precision' => 3)));
     $this->assertTrue(Validator::isDecimal(+0.277, null, array('precision' => 3)));
     $this->assertTrue(Validator::isDecimal('1234.5678', null, array('precision' => '4')));
     $this->assertTrue(Validator::isDecimal(1234.5678, null, array('precision' => 4)));
     $this->assertTrue(Validator::isDecimal(-1234.5678, null, array('precision' => 4)));
     $this->assertTrue(Validator::isDecimal(+1234.5678, null, array('precision' => 4)));
     $this->assertFalse(Validator::isDecimal('1234.5678', null, array('precision' => '3')));
     $this->assertFalse(Validator::isDecimal(1234.5678, null, array('precision' => 3)));
     $this->assertFalse(Validator::isDecimal(-1234.5678, null, array('precision' => 3)));
     $this->assertFalse(Validator::isDecimal(+1234.5678, null, array('precision' => 3)));
 }