コード例 #1
0
 public function testValidation()
 {
     $validator = new ScientificNotationValidator('it_IT');
     $this->assertTrue($validator->isValid('1E3'));
     $this->assertTrue($validator->isValid('1e-3'));
     $this->assertTrue($validator->isValid('1e+3'));
     $this->assertTrue($validator->isValid('1E+3'));
     $this->assertTrue($validator->isValid('1.5E10'));
     $this->assertTrue($validator->isValid('.5E10'));
     $this->assertFalse($validator->isValid('.5E10 ABC'));
     $this->assertFalse($validator->isValid('1E+3 ABC'));
     $this->assertFalse($validator->isValid('1AE+3'));
     $this->assertFalse($validator->isValid(1000.0));
     $this->assertFalse($validator->isValid(1000));
     $this->assertFalse($validator->isValid(NAN));
     $this->assertFalse($validator->isValid(0.5));
     $this->assertFalse($validator->isValid([]));
 }
コード例 #2
0
 /**
  * @param $expected
  * @param $value
  * @param $locale
  * @dataProvider valuesProvider
  */
 public function testAllValues($expected, $value, $locale)
 {
     $this->validator->setLocale($locale);
     $this->assertEquals($expected, $this->validator->isValid($value), sprintf("'Failed expecting '%s' being %s (locale: %s, type: %s)", $value, $expected ? 'TRUE' : 'FALSE', $locale, gettype($value)));
     self::writeData(['locale' => $locale, 'value' => $value, 'valid' => $expected ? 'true' : 'false']);
 }