public function test_it_validates_fields_on_update() { $page = ['page_version_id' => 50, 'page_id' => 42, 'language_id' => 45]; $fields = [['id' => 1, 'model_id' => 1, 'model_type' => 'DvsTestModel', 'mapping' => 'Name', 'json_value' => '{}', 'values' => ['foo' => 'bar']]]; $this->addSomeTestModelFields(); try { $this->ModelManager->updateFields($fields, $page); } catch (ModelFieldValidationFailedException $e) { $field = \DvsModelField::find(1); $model = \DvsTestModel::find(1); assertEquals(1, $model->page_version_id); assertEquals('Some name here', $model->name); assertEquals('{}', $field->json_value); assertInstanceOf('Illuminate\\Support\\MessageBag', $e->getErrors()); assertEquals('The name field is required.', $e->getErrors()->first('name')); return; } throw new \Exception("We should not reach this line unless the model validation exception was not thrown..."); }