Commit 03d15077 authored by lucasvanlierop's avatar lucasvanlierop

Used dataprovider for testConvertFromBoolean

parent 4e7e2dfe
......@@ -336,35 +336,28 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$this->assertEquals(1, $platform->convertBooleansToDatabaseValue(true));
$this->assertEquals(0, $platform->convertBooleansToDatabaseValue(false));
}
public function testConvertFromBoolean()
/**
* @expectedException UnexpectedValueException
* @expectedExceptionMessage Unrecognized boolean literal 'my-bool'
*/
public function testThrowsExceptionWithInvalidBooleanLiteral()
{
$platform = $this->createPlatform()->convertBooleansToDatabaseValue("my-bool");
}
/**
* @dataProvider pgStringBooleanDatabaseValueProvider
*/
public function testConvertFromBoolean($expected, $input)
{
$platform = $this->createPlatform();
$this->assertFalse($platform->convertFromBoolean(false));
$this->assertFalse($platform->convertFromBoolean('false'));
$this->assertFalse($platform->convertFromBoolean('FALSE'));
$this->assertFalse($platform->convertFromBoolean('f'));
$this->assertFalse($platform->convertFromBoolean('F'));
$this->assertFalse($platform->convertFromBoolean('no'));
$this->assertFalse($platform->convertFromBoolean('NO'));
$this->assertFalse($platform->convertFromBoolean('n'));
$this->assertFalse($platform->convertFromBoolean('N'));
$this->assertFalse($platform->convertFromBoolean('off'));
$this->assertFalse($platform->convertFromBoolean('OFF'));
$this->assertFalse($platform->convertFromBoolean('0'));
$this->assertTrue($platform->convertFromBoolean(true));
$this->assertTrue($platform->convertFromBoolean('true'));
$this->assertTrue($platform->convertFromBoolean('TRUE'));
$this->assertTrue($platform->convertFromBoolean('t'));
$this->assertTrue($platform->convertFromBoolean('T'));
$this->assertTrue($platform->convertFromBoolean('yes'));
$this->assertTrue($platform->convertFromBoolean('YES'));
$this->assertTrue($platform->convertFromBoolean('y'));
$this->assertTrue($platform->convertFromBoolean('Y'));
$this->assertTrue($platform->convertFromBoolean('on'));
$this->assertTrue($platform->convertFromBoolean('ON'));
$this->assertTrue($platform->convertFromBoolean('1'));
if ($expected === 1) {
$this->assertTrue($platform->convertFromBoolean($input));
} else {
$this->assertFalse($platform->convertFromBoolean($input));
}
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment