Skip to content
Permalink
Browse files

FIX Updated unit test were targeting Float/Int which don't exist on P…

…HP7 (#8810)
  • Loading branch information
maxime-rainville authored and unclecheese committed Feb 19, 2019
1 parent 8c9e8fb commit ab5f09a9f3ec12333c748dd68bfc504b5e509bfc
Showing with 16 additions and 18 deletions.
  1. +16 −18 tests/model/DBFieldTest.php
@@ -14,22 +14,20 @@ class DBFieldTest extends SapphireTest {
*/
public function testNullValue() {
/* Float and Double use 0 for "null" value representation */
$this->assertEquals(0, singleton('Float')->nullValue());
$this->assertEquals(0, singleton('DBFloat')->nullValue());
$this->assertEquals(0, singleton('Double')->nullValue());
}
/**
* Test the prepValueForDB() method on DBField.
*/
public function testPrepValueForDB() {
$db = DB::get_conn();
/* Float behaviour, asserting we have 0 */
$this->assertEquals(0, singleton('Float')->prepValueForDB(0));
$this->assertEquals(0, singleton('Float')->prepValueForDB(null));
$this->assertEquals(0, singleton('Float')->prepValueForDB(false));
$this->assertEquals(0, singleton('Float')->prepValueForDB(''));
$this->assertEquals('0', singleton('Float')->prepValueForDB('0'));
$this->assertEquals(0, singleton('DBFloat')->prepValueForDB(0));
$this->assertEquals(0, singleton('DBFloat')->prepValueForDB(null));
$this->assertEquals(0, singleton('DBFloat')->prepValueForDB(false));
$this->assertEquals(0, singleton('DBFloat')->prepValueForDB(''));
$this->assertEquals('0', singleton('DBFloat')->prepValueForDB('0'));
/* Double behaviour, asserting we have 0 */
$this->assertEquals(0, singleton('Double')->prepValueForDB(0));
@@ -39,16 +37,16 @@ public function testPrepValueForDB() {
$this->assertEquals('0', singleton('Double')->prepValueForDB('0'));
/* Integer behaviour, asserting we have 0 */
$this->assertEquals(0, singleton('Int')->prepValueForDB(0));
$this->assertEquals(0, singleton('Int')->prepValueForDB(null));
$this->assertEquals(0, singleton('Int')->prepValueForDB(false));
$this->assertEquals(0, singleton('Int')->prepValueForDB(''));
$this->assertEquals('0', singleton('Int')->prepValueForDB('0'));
$this->assertEquals(0, singleton('DBInt')->prepValueForDB(0));
$this->assertEquals(0, singleton('DBInt')->prepValueForDB(null));
$this->assertEquals(0, singleton('DBInt')->prepValueForDB(false));
$this->assertEquals(0, singleton('DBInt')->prepValueForDB(''));
$this->assertEquals('0', singleton('DBInt')->prepValueForDB('0'));
/* Integer behaviour, asserting we have 1 */
$this->assertEquals(1, singleton('Int')->prepValueForDB(true));
$this->assertEquals(1, singleton('Int')->prepValueForDB(1));
$this->assertEquals('1', singleton('Int')->prepValueForDB('1'));
$this->assertEquals(1, singleton('DBInt')->prepValueForDB(true));
$this->assertEquals(1, singleton('DBInt')->prepValueForDB(1));
$this->assertEquals('1', singleton('DBInt')->prepValueForDB('1'));
/* Decimal behaviour, asserting we have 0 */
$this->assertEquals(0, singleton('Decimal')->prepValueForDB(0));
@@ -197,11 +195,11 @@ public function dataProviderPrepValueForDBArrayValue()
array('Decimal', true),
array('Double', true),
array('Enum', true),
array('Float', true),
array('DBFloat', true),
array('ForeignKey', true, array('SomeField')),
array('HTMLText', true),
array('HTMLVarchar', true),
array('Int', true),
array('DBInt', true),
array('Money', false),
array('MultiEnum', true, array('SomeField', array('One', 'Two', 'Three'))),
array('Percentage', true),

0 comments on commit ab5f09a

Please sign in to comment.
You can’t perform that action at this time.