Merge pull request #46 from sc0Vu/fix-45

Fix #45
This commit is contained in:
Kuan-Cheng,Lai 2018-02-21 09:57:59 +08:00 committed by GitHub
commit d89e7d1884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -4,4 +4,4 @@ require('../vendor/autoload.php');
use Web3\Web3;
$web3 = new Web3('http://192.168.99.100:8545');
$web3 = new Web3('http://192.168.99.100:8545/');

View File

@ -21,13 +21,10 @@ class BooleanFormatter implements IFormatter
* format
*
* @param mixed $value
* @return int
* @return bool
*/
public static function format($value)
{
if (!is_bool($value)) {
throw new InvalidArgumentException('The value to inputFormat function must be boolean.');
}
return (int) $value;
return (bool) $value;
}
}

View File

@ -36,12 +36,15 @@ class BooleanFormatterTest extends TestCase
$formatter = $this->formatter;
$boolean = $formatter->format(true);
$this->assertEquals($boolean, 1);
$this->assertEquals($boolean, true);
$boolean = $formatter->format(1);
$this->assertEquals($boolean, true);
$boolean = $formatter->format(false);
$this->assertEquals($boolean, 0);
$this->assertEquals($boolean, false);
$this->expectException(InvalidArgumentException::class);
$boolean = $formatter->format('boolean');
$boolean = $formatter->format(0);
$this->assertEquals($boolean, false);
}
}