Improve nullable tests

Refs https://github.com/octobercms/october/issues/2612
This commit is contained in:
Samuel Georges 2017-02-02 05:15:47 +11:00
parent 13aef49ebb
commit 8d1ecb01b8
1 changed files with 20 additions and 1 deletions

View File

@ -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);
}
}