public function testCustomValidation()
 {
     /* @var $nameField \Mindy\Orm\Fields\Field */
     $model = new User();
     $this->assertFalse($model->isValid());
     $this->assertEquals(['username' => ['Cannot be empty', 'Minimal length is 3']], $model->getErrors());
     $nameField = $model->getField('username');
     $this->assertEquals(['Cannot be empty', 'Minimal length is 3'], $nameField->getErrors());
     $this->assertFalse($nameField->isValid());
     $this->assertEquals(['Cannot be empty', 'Minimal length is 3'], $nameField->getErrors());
     $model->username = '******';
     $this->assertEquals('hi', $model->username);
     $this->assertFalse($model->isValid());
     $this->assertEquals('hi', $model->username);
     $model->username = '******';
     $model->isValid();
     $this->assertEquals(['username' => ['Maximum length is 20']], $model->getErrors());
     $model->isValid();
     $this->assertEquals(['username' => ['Maximum length is 20']], $model->getErrors());
 }
 public function testSaveSelectedField()
 {
     $model = new User();
     $model->username = '******';
     $model->password = '******';
     $this->assertEquals(0, User::objects()->count());
     $this->assertTrue($model->getIsNewRecord());
     $this->assertTrue($model->isValid());
     $this->assertNull($model->pk);
     $this->assertEquals('Anton', $model->username);
     $this->assertEquals('VeryGoodP@ssword', $model->password);
     $saved = $model->save(['username']);
     $this->assertTrue($saved);
     $this->assertEquals(1, User::objects()->count());
     $this->assertFalse($model->getIsNewRecord());
     $this->assertEquals(1, $model->pk);
     $this->assertEquals('Anton', $model->username);
     $this->assertEquals('VeryGoodP@ssword', $model->password);
     $model = User::objects()->get();
     $this->assertNull($model->password);
 }