A free open source IT asset/license management system
Fixed custom field mac address factory
snipe21cab313deaa
diff --git a/database/factories/CustomFieldFactory.php b/database/factories/CustomFieldFactory.phpindex 3f12ef52c6..8835f77340 100644--- a/database/factories/CustomFieldFactory.php+++ b/database/factories/CustomFieldFactory.php@@ -76,9 +76,10 @@ class CustomFieldFactory extends Factorypublic function macAddress(){+ // Name has to be unique per factory callreturn $this->state(function () {return [- 'name' => 'MAC Address',+ 'name' => $this->faker->unique()->bothify('MAC Address ##??##'),'format' => 'regex:/^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/',];});diff --git a/tests/Feature/Assets/Api/StoreAssetTest.php b/tests/Feature/Assets/Api/StoreAssetTest.phpindex 9db0791c39..a590045faa 100644--- a/tests/Feature/Assets/Api/StoreAssetTest.php+++ b/tests/Feature/Assets/Api/StoreAssetTest.php@@ -802,7 +802,7 @@ class StoreAssetTest extends TestCase$model = AssetModel::factory()->create(['fieldset_id' => $fieldset->id]);$model->defaultValues()->attach([- $fieldA->id => ['default_value' => 'default-mac'],+ $fieldA->id => ['default_value' => 'aa:bb:cc:dd:ee:ff'],$fieldB->id => ['default_value' => 'default-ram'],$fieldC->id => ['default_value' => 'default-cpu'],]);diff --git a/tests/Feature/CustomFieldsets/Api/FieldsWithDefaultValuesTest.php b/tests/Feature/CustomFieldsets/Api/FieldsWithDefaultValuesTest.phpindex 8d89dd0774..35481fe6e7 100644--- a/tests/Feature/CustomFieldsets/Api/FieldsWithDefaultValuesTest.php+++ b/tests/Feature/CustomFieldsets/Api/FieldsWithDefaultValuesTest.php@@ -15,8 +15,8 @@ class FieldsWithDefaultValuesTest extends TestCase{$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');- $fieldA = CustomField::factory()->create(['name' => 'FieldOneName']);- $fieldB = CustomField::factory()->create(['name' => 'FieldTwoName']);+ $fieldA = CustomField::factory()->macAddress()->create();+ $fieldB = CustomField::factory()->ram()->create();$fieldset = CustomFieldset::factory()->create();$fieldset->fields()->attach($fieldA->id, ['order' => 1, 'required' => false]);@@ -42,6 +42,9 @@ class FieldsWithDefaultValuesTest extends TestCase}$this->assertSame('aa:bb:cc:dd:ee:ff', $byId[$fieldA->id]['default_value']);$this->assertSame('16GB', $byId[$fieldB->id]['default_value']);++ $this->assertNotNull($fieldA->id, 'macAddress() factory should persist');+ $this->assertNotNull($fieldB->id, 'ram() factory should persist');}public function test_does_not_lazy_load_default_values_per_field()@@ -57,9 +60,9 @@ class FieldsWithDefaultValuesTest extends TestCase// pivot walk collapses to a single query.$this->markIncompleteIfMySQL('Custom Fields tests do not work on MySQL');- $fieldA = CustomField::factory()->create(['name' => 'RegressionFieldA']);- $fieldB = CustomField::factory()->create(['name' => 'RegressionFieldB']);- $fieldC = CustomField::factory()->create(['name' => 'RegressionFieldC']);+ $fieldA = CustomField::factory()->macAddress()->create();+ $fieldB = CustomField::factory()->ram()->create();+ $fieldC = CustomField::factory()->cpu()->create();$fieldset = CustomFieldset::factory()->create();$fieldset->fields()->attach($fieldA->id, ['order' => 1, 'required' => false]);