Browse Source

Add "default" key for form schema fields.

ADmad 8 years ago
parent
commit
efef498557
2 changed files with 6 additions and 5 deletions
  1. 1 0
      src/Form/Schema.php
  2. 5 5
      tests/TestCase/Form/SchemaTest.php

+ 1 - 0
src/Form/Schema.php

@@ -36,6 +36,7 @@ class Schema
         'type' => null,
         'length' => null,
         'precision' => null,
+        'default' => null,
     ];
 
     /**

+ 5 - 5
tests/TestCase/Form/SchemaTest.php

@@ -54,7 +54,7 @@ class SchemaTest extends TestCase
 
         $this->assertEquals(['name'], $schema->fields());
         $res = $schema->field('name');
-        $expected = ['type' => 'string', 'length' => null, 'precision' => null];
+        $expected = ['type' => 'string', 'length' => null, 'precision' => null, 'default' => null];
         $this->assertEquals($expected, $res);
 
         $res = $schema->addField('email', 'string');
@@ -62,7 +62,7 @@ class SchemaTest extends TestCase
 
         $this->assertEquals(['name', 'email'], $schema->fields());
         $res = $schema->field('email');
-        $expected = ['type' => 'string', 'length' => null, 'precision' => null];
+        $expected = ['type' => 'string', 'length' => null, 'precision' => null, 'default' => null];
         $this->assertEquals($expected, $res);
     }
 
@@ -76,7 +76,7 @@ class SchemaTest extends TestCase
         $schema = new Schema();
 
         $schema->addField('name', ['derp' => 'derp', 'type' => 'string']);
-        $expected = ['type' => 'string', 'length' => null, 'precision' => null];
+        $expected = ['type' => 'string', 'length' => null, 'precision' => null, 'default' => null];
         $this->assertEquals($expected, $schema->field('name'));
     }
 
@@ -134,8 +134,8 @@ class SchemaTest extends TestCase
         $result = $schema->__debugInfo();
         $expected = [
             '_fields' => [
-                'name' => ['type' => 'string', 'length' => null, 'precision' => null],
-                'numbery' => ['type' => 'decimal', 'length' => null, 'precision' => null],
+                'name' => ['type' => 'string', 'length' => null, 'precision' => null, 'default' => null],
+                'numbery' => ['type' => 'decimal', 'length' => null, 'precision' => null, 'default' => null],
             ],
         ];
         $this->assertEquals($expected, $result);