Skip to content
Permalink
Browse files

Add "default" key for form schema fields.

  • Loading branch information...
ADmad committed Oct 4, 2017
1 parent 20840d8 commit efef4985571e708e26700b72ba1f02448af81220
Showing with 6 additions and 5 deletions.
  1. +1 −0 src/Form/Schema.php
  2. +5 −5 tests/TestCase/Form/SchemaTest.php
@@ -36,6 +36,7 @@ class Schema
'type' => null,
'length' => null,
'precision' => null,
'default' => null,
];
/**
@@ -54,15 +54,15 @@ public function testAddingFields()
$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');
$this->assertSame($schema, $res, 'Should be chainable');
$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 @@ public function testAddingFieldsWhitelist()
$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 @@ public function testDebugInfo()
$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);

0 comments on commit efef498

Please sign in to comment.
You can’t perform that action at this time.