Esempio n. 1
0
 public function test_it_validates_fields_on_create()
 {
     $page = ['page_version_id' => 50, 'page_id' => 42, 'language_id' => 45];
     $fields = [['id' => 'Name', 'model_type' => 'DvsTestModel', 'mapping' => 'Name', 'values' => ['text' => '']]];
     $previousFieldCount = \DvsModelField::count();
     $previousModelCount = \DvsTestModel::count();
     try {
         list($createdFields, $createdModel) = $this->ModelManager->createFieldsAndModel($fields, $page);
     } catch (ModelFieldValidationFailedException $e) {
         // make sure we don't end up with leftover crap in db
         assertEquals($previousFieldCount, \DvsModelField::count());
         assertEquals($previousModelCount, \DvsTestModel::count());
         assertInstanceOf('Illuminate\\Support\\MessageBag', $e->getErrors());
         assertEquals('The name field is required.', $e->getErrors()->first('name'));
         return;
     }
     throw new \Exception("This line should not execute unless a ModelFieldValidationFailedException was not thrown");
 }