From 8d1ecb01b8128659003f5977dd7a8900deb1544f Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Thu, 2 Feb 2017 05:15:47 +1100 Subject: [PATCH] Improve nullable tests Refs https://github.com/octobercms/october/issues/2612 --- .../plugins/database/NullableModelTest.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/unit/plugins/database/NullableModelTest.php b/tests/unit/plugins/database/NullableModelTest.php index 0b9f258b5..0484409d4 100644 --- a/tests/unit/plugins/database/NullableModelTest.php +++ b/tests/unit/plugins/database/NullableModelTest.php @@ -31,9 +31,28 @@ class NullableModelTest extends PluginTestCase $post = NullablePost::create(['author_nickname' => 'Joe']); $this->assertEquals('Joe', $post->author_nickname); - // Save as "not equal" operator + // Save as zero integer $post->author_nickname = 0; $post->save(); + $this->assertNotNull($post->author_nickname); $this->assertEquals(0, $post->author_nickname); + + // Save as zero float + $post->author_nickname = 0.0; + $post->save(); + $this->assertNotNull($post->author_nickname); + $this->assertEquals(0.0, $post->author_nickname); + + // Save as zero string + $post->author_nickname = '0'; + $post->save(); + $this->assertNotNull($post->author_nickname); + $this->assertEquals('0', $post->author_nickname); + + // Save as false + $post->author_nickname = false; + $post->save(); + $this->assertNotNull($post->author_nickname); + $this->assertEquals(false, $post->author_nickname); } }