Browse Source

Fix deprecated Form::schema() calls

chinpei215 6 years ago
parent
commit
1fc29a558e
2 changed files with 8 additions and 8 deletions
  1. 4 4
      src/View/Form/FormContext.php
  2. 4 4
      tests/TestCase/View/Form/FormContextTest.php

+ 4 - 4
src/View/Form/FormContext.php

@@ -128,7 +128,7 @@ class FormContext implements ContextInterface
      */
     protected function _schemaDefault(string $field)
     {
-        $field = $this->_form->schema()->field($field);
+        $field = $this->_form->getSchema()->field($field);
         if ($field) {
             return $field['default'];
         }
@@ -201,7 +201,7 @@ class FormContext implements ContextInterface
      */
     public function fieldNames(): array
     {
-        return $this->_form->schema()->fields();
+        return $this->_form->getSchema()->fields();
     }
 
     /**
@@ -209,7 +209,7 @@ class FormContext implements ContextInterface
      */
     public function type(string $field): ?string
     {
-        return $this->_form->schema()->fieldType($field);
+        return $this->_form->getSchema()->fieldType($field);
     }
 
     /**
@@ -217,7 +217,7 @@ class FormContext implements ContextInterface
      */
     public function attributes(string $field): array
     {
-        $column = (array)$this->_form->schema()->field($field);
+        $column = (array)$this->_form->getSchema()->field($field);
         $whiteList = ['length' => null, 'precision' => null];
 
         return array_intersect_key($column, $whiteList);

+ 4 - 4
tests/TestCase/View/Form/FormContextTest.php

@@ -156,7 +156,7 @@ class FormContextTest extends TestCase
     public function testValDefault()
     {
         $form = new Form();
-        $form->schema()->addField('name', ['default' => 'schema default']);
+        $form->getSchema()->addField('name', ['default' => 'schema default']);
         $context = new FormContext($this->request, ['entity' => $form]);
 
         $result = $context->val('title');
@@ -204,7 +204,7 @@ class FormContextTest extends TestCase
     public function testType()
     {
         $form = new Form();
-        $form->schema()
+        $form->getSchema()
             ->addField('email', 'string')
             ->addField('user_id', 'integer');
 
@@ -232,7 +232,7 @@ class FormContextTest extends TestCase
         $result = $context->fieldNames();
         $this->assertEquals($expected, $result);
 
-        $form->schema()
+        $form->getSchema()
             ->addField('email', 'string')
             ->addField('password', 'string');
         $context = new FormContext($this->request, [
@@ -252,7 +252,7 @@ class FormContextTest extends TestCase
     public function testAttributes()
     {
         $form = new Form();
-        $form->schema()
+        $form->getSchema()
             ->addField('email', [
                 'type' => 'string',
                 'length' => 10,