public function testEmptyStringAttribute() { $postFirst = ['enable' => 1, 'visible' => 1, 'string' => '', 'content@1' => 'Content 1', 'title@1' => 'Title 1', 'content@2' => 'Content 2', 'title@2' => 'Title 2']; $this->obj->import($postFirst); $this->assertEquals($postFirst['enable'], $this->obj->getNonMultilang()->last()->enable); $this->assertEquals($postFirst['visible'], $this->obj->getNonMultilang()->last()->visible); $this->assertEquals(null, $this->obj->getNonMultilang()->last()->string); }
/** * to valitate * * @return boolean false, if it is failed. */ private function validate() { $v = $this->validator->make($this->picker->getSource(), $this->getRules()); if ($v->fails()) { // to set errors messages $this->message = $v->getMessageBag(); // failed! return false; } // passed! return true; }
/** * to check required implement and import post data. In addition, * validate post data. * * @param array $post Post Data. It usualy is be array * @param Muratsplat\Multilang\Interfaces\MainInterface $model main model * @param array $rules not required. Laravel validation rules in a array * @return bool true, it is on success */ protected function checkdata(array $post, Model $model, array $rules) { $this->checkMainImplement($model); // if post is empty, something must be wrong!! if (empty($post)) { throw new MultilangPostEmpty('Post Data is empty, ' . 'MultiLang needs to acceptable Post Data!'); } $this->picker->import($post); if (!$this->validateAll($model, $rules)) { return false; } return true; }