Browse Source

Fix deprecation warnings in View & Tests.

Mark Story 8 years ago
parent
commit
b89f57178b

+ 2 - 2
src/View/Form/EntityContext.php

@@ -136,7 +136,7 @@ class EntityContext implements ContextInterface
             $isEntity = $entity instanceof EntityInterface;
 
             if ($isEntity) {
-                $table = $entity->source();
+                $table = $entity->getSource();
             }
             if (!$table && $isEntity && get_class($entity) !== 'Cake\ORM\Entity') {
                 list(, $entityClass) = namespaceSplit(get_class($entity));
@@ -581,7 +581,7 @@ class EntityContext implements ContextInterface
         $entity = $this->entity($parts);
 
         if ($entity instanceof EntityInterface) {
-            return $entity->errors(array_pop($parts));
+            return $entity->getError(array_pop($parts));
         }
 
         return [];

+ 2 - 2
tests/TestCase/Datasource/FactoryLocatorTest.php

@@ -86,7 +86,7 @@ class FactoryLocatorTest extends TestCase
     {
         $stub = new Stub();
         $stub->setProps('Articles');
-        $stub->modelType('Table');
+        $stub->setModelType('Table');
 
         $result = $stub->loadModel('TestPlugin.Comments');
         $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
@@ -136,7 +136,7 @@ class FactoryLocatorTest extends TestCase
 
             return $mock;
         });
-        $stub->modelType('Test');
+        $stub->setModelType('Test');
 
         $result = $stub->loadModel('Magic');
         $this->assertInstanceOf('\StdClass', $result);

+ 19 - 16
tests/TestCase/Datasource/ModelAwareTraitTest.php

@@ -60,7 +60,7 @@ class ModelAwareTraitTest extends TestCase
     {
         $stub = new Stub();
         $stub->setProps('Articles');
-        $stub->modelType('Table');
+        $stub->setModelType('Table');
 
         $result = $stub->loadModel();
         $this->assertInstanceOf('Cake\ORM\Table', $result);
@@ -83,7 +83,7 @@ class ModelAwareTraitTest extends TestCase
     {
         $stub = new Stub();
         $stub->setProps('Articles');
-        $stub->modelType('Table');
+        $stub->setModelType('Table');
 
         $result = $stub->loadModel('TestPlugin.Comments');
         $this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
@@ -120,25 +120,28 @@ class ModelAwareTraitTest extends TestCase
     /**
      * test alternate default model type.
      *
+     * @group deprecated
      * @return void
      */
     public function testModelType()
     {
-        $stub = new Stub();
-        $stub->setProps('Articles');
-
-        FactoryLocator::add('Test', function ($name) {
-            $mock = new \StdClass();
-            $mock->name = $name;
-
-            return $mock;
+        $this->deprecated(function () {
+            $stub = new Stub();
+            $stub->setProps('Articles');
+
+            FactoryLocator::add('Test', function ($name) {
+                $mock = new \StdClass();
+                $mock->name = $name;
+
+                return $mock;
+            });
+            $stub->modelType('Test');
+
+            $result = $stub->loadModel('Magic');
+            $this->assertInstanceOf('\StdClass', $result);
+            $this->assertInstanceOf('\StdClass', $stub->Magic);
+            $this->assertEquals('Magic', $stub->Magic->name);
         });
-        $stub->modelType('Test');
-
-        $result = $stub->loadModel('Magic');
-        $this->assertInstanceOf('\StdClass', $result);
-        $this->assertInstanceOf('\StdClass', $stub->Magic);
-        $this->assertEquals('Magic', $stub->Magic->name);
     }
 
     /**

+ 13 - 13
tests/TestCase/Datasource/RulesCheckerTest.php

@@ -44,12 +44,12 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertTrue($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
         $this->assertTrue($rules->check($entity, RulesChecker::UPDATE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
 
         $this->assertFalse($rules->check($entity, RulesChecker::DELETE));
-        $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
+        $this->assertEquals(['ruleName' => 'invalid'], $entity->getError('name'));
     }
 
     /**
@@ -73,12 +73,12 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertTrue($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
         $this->assertTrue($rules->check($entity, RulesChecker::DELETE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
 
         $this->assertFalse($rules->check($entity, RulesChecker::UPDATE));
-        $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
+        $this->assertEquals(['ruleName' => 'invalid'], $entity->getError('name'));
     }
 
     /**
@@ -102,12 +102,12 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertTrue($rules->check($entity, RulesChecker::UPDATE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
         $this->assertTrue($rules->check($entity, RulesChecker::DELETE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
 
         $this->assertFalse($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
+        $this->assertEquals(['ruleName' => 'invalid'], $entity->getError('name'));
     }
 
     /**
@@ -131,7 +131,7 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertFalse($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
+        $this->assertEquals(['ruleName' => 'invalid'], $entity->getError('name'));
     }
 
     /**
@@ -154,7 +154,7 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertFalse($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEquals(['worst thing ever'], $entity->errors('name'));
+        $this->assertEquals(['worst thing ever'], $entity->getError('name'));
     }
 
     /**
@@ -177,7 +177,7 @@ class RulesCheckerTest extends TestCase
         );
 
         $this->assertFalse($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEquals(['this is bad'], $entity->errors('name'));
+        $this->assertEquals(['this is bad'], $entity->getError('name'));
     }
 
     /**
@@ -197,6 +197,6 @@ class RulesCheckerTest extends TestCase
         });
 
         $this->assertFalse($rules->check($entity, RulesChecker::CREATE));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
     }
 }

+ 1 - 1
tests/TestCase/ORM/Association/BelongsToManyTest.php

@@ -854,7 +854,7 @@ class BelongsToManyTest extends TestCase
         ];
         $result = $assoc->replaceLinks($entity, $tags);
         $this->assertFalse($result, 'replace should have failed.');
-        $this->assertNotEmpty($tags[0]->errors(), 'Bad entity should have errors.');
+        $this->assertNotEmpty($tags[0]->getErrors(), 'Bad entity should have errors.');
 
         $entity = $articles->get(1, ['contain' => 'Tags']);
         $this->assertCount($originalCount, $entity->tags, 'Should not have changed.');

+ 7 - 7
tests/TestCase/ORM/Behavior/TranslateBehaviorTest.php

@@ -1574,7 +1574,7 @@ class TranslateBehaviorTest extends TestCase
         $entity = $table->newEntity();
         $result = $map['_translations']('garbage', $entity);
         $this->assertNull($result, 'Non-array should not error out.');
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
         $this->assertEmpty($entity->get('_translations'));
     }
 
@@ -1602,7 +1602,7 @@ class TranslateBehaviorTest extends TestCase
             ]
         ];
         $result = $map['_translations']($data, $entity);
-        $this->assertEmpty($entity->errors(), 'No validation errors.');
+        $this->assertEmpty($entity->getErrors(), 'No validation errors.');
         $this->assertCount(2, $result);
         $this->assertArrayHasKey('en', $result);
         $this->assertArrayHasKey('es', $result);
@@ -1639,13 +1639,13 @@ class TranslateBehaviorTest extends TestCase
             ]
         ];
         $result = $map['_translations']($data, $entity);
-        $this->assertNotEmpty($entity->errors(), 'Needs validation errors.');
+        $this->assertNotEmpty($entity->getErrors(), 'Needs validation errors.');
         $expected = [
             'title' => [
                 '_empty' => 'This field cannot be left empty'
             ]
         ];
-        $this->assertEquals($expected, $entity->errors('es'));
+        $this->assertEquals($expected, $entity->getError('es'));
 
         $this->assertEquals('English Title', $result['en']->title);
         $this->assertEquals('', $result['es']->title);
@@ -1681,7 +1681,7 @@ class TranslateBehaviorTest extends TestCase
             ]
         ];
         $result = $map['_translations']($data, $entity);
-        $this->assertEmpty($entity->errors(), 'No validation errors.');
+        $this->assertEmpty($entity->getErrors(), 'No validation errors.');
         $this->assertSame($en, $result['en']);
         $this->assertSame($es, $result['es']);
         $this->assertSame($en, $entity->get('_translations')['en']);
@@ -1728,12 +1728,12 @@ class TranslateBehaviorTest extends TestCase
             ]
         ];
         $result = $map['_translations']($data, $entity);
-        $this->assertNotEmpty($entity->errors(), 'Needs validation errors.');
+        $this->assertNotEmpty($entity->getErrors(), 'Needs validation errors.');
         $expected = [
             'title' => [
                 '_empty' => 'This field cannot be left empty'
             ]
         ];
-        $this->assertEquals($expected, $entity->errors('es'));
+        $this->assertEquals($expected, $entity->getError('es'));
     }
 }

+ 163 - 133
tests/TestCase/ORM/EntityTest.php

@@ -56,7 +56,7 @@ class EntityTest extends TestCase
     public function testSetMultiplePropertiesNoSetters()
     {
         $entity = new Entity();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $entity->set(['foo' => 'bar', 'id' => 1]);
         $this->assertEquals('bar', $entity->foo);
@@ -186,7 +186,7 @@ class EntityTest extends TestCase
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
             ->setMethods(['_setName', '_setStuff'])
             ->getMock();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->expects($this->once())->method('_setName')
             ->with('Jones')
             ->will($this->returnCallback(function ($name) {
@@ -216,7 +216,7 @@ class EntityTest extends TestCase
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
             ->setMethods(['_setName', '_setStuff'])
             ->getMock();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $entity->expects($this->never())->method('_setName');
         $entity->expects($this->never())->method('_setStuff');
@@ -364,7 +364,7 @@ class EntityTest extends TestCase
             ->will($this->returnCallback(function ($name) {
                 return 'A name';
             }));
-        $entity->virtualProperties(['ListIdName']);
+        $entity->setVirtual(['ListIdName']);
         $this->assertSame('A name', $entity->list_id_name, 'underscored virtual field should be accessible');
         $this->assertSame('A name', $entity->listIdName, 'Camelbacked virtual field should be accessible');
     }
@@ -628,7 +628,7 @@ class EntityTest extends TestCase
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
             ->setMethods(['set'])
             ->getMock();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $entity->expects($this->at(0))
             ->method('set')
@@ -780,17 +780,15 @@ class EntityTest extends TestCase
             'title' => 'Foo',
             'author_id' => 3
         ]);
-        $this->assertTrue($entity->dirty('id'));
         $this->assertTrue($entity->isDirty('id'));
         $this->assertTrue($entity->isDirty('title'));
         $this->assertTrue($entity->isDirty('author_id'));
 
-        $this->assertTrue($entity->dirty());
         $this->assertTrue($entity->isDirty());
 
-        $entity->dirty('id', false);
-        $this->assertFalse($entity->dirty('id'));
-        $this->assertTrue($entity->dirty('title'));
+        $entity->setDirty('id', false);
+        $this->assertFalse($entity->isDirty('id'));
+        $this->assertTrue($entity->isDirty('title'));
 
         $entity->setDirty('title', false);
         $this->assertFalse($entity->isDirty('title'));
@@ -1055,7 +1053,7 @@ class EntityTest extends TestCase
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
             ->setMethods(['_getName'])
             ->getMock();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->set(['name' => 'Mark', 'email' => 'mark@example.com']);
         $entity->expects($this->any())
             ->method('_getName')
@@ -1074,7 +1072,7 @@ class EntityTest extends TestCase
     {
         $data = ['secret' => 'sauce', 'name' => 'mark', 'id' => 1];
         $entity = new Entity($data);
-        $entity->hiddenProperties(['secret']);
+        $entity->setHidden(['secret']);
         $this->assertEquals(['name' => 'mark', 'id' => 1], $entity->toArray());
     }
 
@@ -1132,23 +1130,23 @@ class EntityTest extends TestCase
         $entity = $this->getMockBuilder('\Cake\ORM\Entity')
             ->setMethods(['_getName'])
             ->getMock();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $entity->expects($this->any())
             ->method('_getName')
             ->will($this->returnValue('Jose'));
         $entity->set(['email' => 'mark@example.com']);
 
-        $entity->virtualProperties(['name']);
+        $entity->setVirtual(['name']);
         $expected = ['name' => 'Jose', 'email' => 'mark@example.com'];
         $this->assertEquals($expected, $entity->toArray());
 
-        $this->assertEquals(['name'], $entity->virtualProperties());
+        $this->assertEquals(['name'], $entity->getVirtual());
 
-        $entity->hiddenProperties(['name']);
+        $entity->setHidden(['name']);
         $expected = ['email' => 'mark@example.com'];
         $this->assertEquals($expected, $entity->toArray());
-        $this->assertEquals(['name'], $entity->hiddenProperties());
+        $this->assertEquals(['name'], $entity->getHidden());
     }
 
     /**
@@ -1178,35 +1176,38 @@ class EntityTest extends TestCase
     /**
      * Tests the errors method
      *
+     * @group deprecated
      * @return void
      */
     public function testErrors()
     {
-        $entity = new Entity();
-        $this->assertEmpty($entity->errors());
-        $this->assertSame($entity, $entity->errors('foo', 'bar'));
-        $this->assertEquals(['bar'], $entity->errors('foo'));
-
-        $this->assertEquals([], $entity->errors('boo'));
-        $entity['boo'] = [
-            'something' => 'stupid',
-            'and' => false
-        ];
-        $this->assertEquals([], $entity->errors('boo'));
+        $this->deprecated(function () {
+            $entity = new Entity();
+            $this->assertEmpty($entity->errors());
+            $this->assertSame($entity, $entity->errors('foo', 'bar'));
+            $this->assertEquals(['bar'], $entity->errors('foo'));
+
+            $this->assertEquals([], $entity->errors('boo'));
+            $entity['boo'] = [
+                'something' => 'stupid',
+                'and' => false
+            ];
+            $this->assertEquals([], $entity->errors('boo'));
 
-        $entity->errors('foo', 'other error');
-        $this->assertEquals(['bar', 'other error'], $entity->errors('foo'));
+            $entity->errors('foo', 'other error');
+            $this->assertEquals(['bar', 'other error'], $entity->errors('foo'));
 
-        $entity->errors('bar', ['something', 'bad']);
-        $this->assertEquals(['something', 'bad'], $entity->errors('bar'));
+            $entity->errors('bar', ['something', 'bad']);
+            $this->assertEquals(['something', 'bad'], $entity->errors('bar'));
 
-        $expected = ['foo' => ['bar', 'other error'], 'bar' => ['something', 'bad']];
-        $this->assertEquals($expected, $entity->errors());
+            $expected = ['foo' => ['bar', 'other error'], 'bar' => ['something', 'bad']];
+            $this->assertEquals($expected, $entity->errors());
 
-        $errors = ['foo' => ['something'], 'bar' => 'else', 'baz' => ['error']];
-        $this->assertSame($entity, $entity->errors($errors, null, true));
-        $errors['bar'] = ['else'];
-        $this->assertEquals($errors, $entity->errors());
+            $errors = ['foo' => ['something'], 'bar' => 'else', 'baz' => ['error']];
+            $this->assertSame($entity, $entity->errors($errors, null, true));
+            $errors['bar'] = ['else'];
+            $this->assertEquals($errors, $entity->errors());
+        });
     }
 
     /**
@@ -1220,7 +1221,7 @@ class EntityTest extends TestCase
         $this->assertEmpty($entity->getErrors());
 
         $entity->setError('foo', 'bar');
-        $this->assertEquals(['bar'], $entity->errors('foo'));
+        $this->assertEquals(['bar'], $entity->getError('foo'));
 
         $expected = [
             'foo' => ['bar']
@@ -1244,30 +1245,30 @@ class EntityTest extends TestCase
             'user' => $user,
             'owner' => $owner
         ]);
-        $author->errors('thing', ['this is a mistake']);
-        $user->errors(['a' => ['error1'], 'b' => ['error2']]);
-        $owner->errors(['c' => ['error3'], 'd' => ['error4']]);
+        $author->setError('thing', ['this is a mistake']);
+        $user->setErrors(['a' => ['error1'], 'b' => ['error2']]);
+        $owner->setErrors(['c' => ['error3'], 'd' => ['error4']]);
 
         $expected = ['a' => ['error1'], 'b' => ['error2']];
-        $this->assertEquals($expected, $author->errors('user'));
+        $this->assertEquals($expected, $author->getError('user'));
 
         $expected = ['c' => ['error3'], 'd' => ['error4']];
-        $this->assertEquals($expected, $author->errors('owner'));
+        $this->assertEquals($expected, $author->getError('owner'));
 
         $author->set('multiple', [$user, $owner]);
         $expected = [
             ['a' => ['error1'], 'b' => ['error2']],
             ['c' => ['error3'], 'd' => ['error4']]
         ];
-        $this->assertEquals($expected, $author->errors('multiple'));
+        $this->assertEquals($expected, $author->getError('multiple'));
 
         $expected = [
-            'thing' => $author->errors('thing'),
-            'user' => $author->errors('user'),
-            'owner' => $author->errors('owner'),
-            'multiple' => $author->errors('multiple')
+            'thing' => $author->getError('thing'),
+            'user' => $author->getError('user'),
+            'owner' => $author->getError('owner'),
+            'multiple' => $author->getError('multiple')
         ];
-        $this->assertEquals($expected, $author->errors());
+        $this->assertEquals($expected, $author->getErrors());
     }
 
     /**
@@ -1284,21 +1285,21 @@ class EntityTest extends TestCase
             'one' => $assoc,
             'many' => [$assoc2]
         ]);
-        $entity->errors('wrong', 'Bad stuff');
-        $assoc->errors('nope', 'Terrible things');
-        $assoc2->errors('nope', 'Terrible things');
+        $entity->setError('wrong', 'Bad stuff');
+        $assoc->setError('nope', 'Terrible things');
+        $assoc2->setError('nope', 'Terrible things');
 
-        $this->assertEquals(['Bad stuff'], $entity->errors('wrong'));
-        $this->assertEquals(['Terrible things'], $entity->errors('many.0.nope'));
-        $this->assertEquals(['Terrible things'], $entity->errors('one.nope'));
-        $this->assertEquals(['nope' => ['Terrible things']], $entity->errors('one'));
-        $this->assertEquals([0 => ['nope' => ['Terrible things']]], $entity->errors('many'));
-        $this->assertEquals(['nope' => ['Terrible things']], $entity->errors('many.0'));
+        $this->assertEquals(['Bad stuff'], $entity->getError('wrong'));
+        $this->assertEquals(['Terrible things'], $entity->getError('many.0.nope'));
+        $this->assertEquals(['Terrible things'], $entity->getError('one.nope'));
+        $this->assertEquals(['nope' => ['Terrible things']], $entity->getError('one'));
+        $this->assertEquals([0 => ['nope' => ['Terrible things']]], $entity->getError('many'));
+        $this->assertEquals(['nope' => ['Terrible things']], $entity->getError('many.0'));
 
-        $this->assertEquals([], $entity->errors('many.0.mistake'));
-        $this->assertEquals([], $entity->errors('one.mistake'));
-        $this->assertEquals([], $entity->errors('one.1.mistake'));
-        $this->assertEquals([], $entity->errors('many.1.nope'));
+        $this->assertEquals([], $entity->getError('many.0.mistake'));
+        $this->assertEquals([], $entity->getError('one.mistake'));
+        $this->assertEquals([], $entity->getError('one.1.mistake'));
+        $this->assertEquals([], $entity->getError('many.1.nope'));
     }
 
     /**
@@ -1310,13 +1311,13 @@ class EntityTest extends TestCase
     public function testDirtyRemovesError()
     {
         $entity = new Entity(['a' => 'b']);
-        $entity->errors('a', 'is not good');
+        $entity->setError('a', 'is not good');
         $entity->set('a', 'c');
-        $this->assertEmpty($entity->errors('a'));
+        $this->assertEmpty($entity->getError('a'));
 
-        $entity->errors('a', 'is not good');
-        $entity->dirty('a', true);
-        $this->assertEmpty($entity->errors('a'));
+        $entity->setError('a', 'is not good');
+        $entity->setDirty('a', true);
+        $this->assertEmpty($entity->getError('a'));
     }
 
     /**
@@ -1327,9 +1328,9 @@ class EntityTest extends TestCase
     public function testCleanRemovesErrors()
     {
         $entity = new Entity(['a' => 'b']);
-        $entity->errors('a', 'is not good');
+        $entity->setError('a', 'is not good');
         $entity->clean();
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
     }
 
     /**
@@ -1340,25 +1341,25 @@ class EntityTest extends TestCase
     public function testAccessible()
     {
         $entity = new Entity();
-        $entity->accessible('*', false);
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertFalse($entity->accessible('bar'));
+        $entity->setAccess('*', false);
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertFalse($entity->isAccessible('bar'));
 
-        $this->assertSame($entity, $entity->accessible('foo', true));
-        $this->assertTrue($entity->accessible('foo'));
-        $this->assertFalse($entity->accessible('bar'));
+        $this->assertSame($entity, $entity->setAccess('foo', true));
+        $this->assertTrue($entity->isAccessible('foo'));
+        $this->assertFalse($entity->isAccessible('bar'));
 
-        $this->assertSame($entity, $entity->accessible('bar', true));
-        $this->assertTrue($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
+        $this->assertSame($entity, $entity->setAccess('bar', true));
+        $this->assertTrue($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
 
-        $this->assertSame($entity, $entity->accessible('foo', false));
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
+        $this->assertSame($entity, $entity->setAccess('foo', false));
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
 
-        $this->assertSame($entity, $entity->accessible('bar', false));
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertFalse($entity->accessible('bar'));
+        $this->assertSame($entity, $entity->setAccess('bar', false));
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertFalse($entity->isAccessible('bar'));
     }
 
     /**
@@ -1369,20 +1370,20 @@ class EntityTest extends TestCase
     public function testAccessibleAsArray()
     {
         $entity = new Entity();
-        $entity->accessible(['foo', 'bar', 'baz'], true);
-        $this->assertTrue($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
-        $this->assertTrue($entity->accessible('baz'));
+        $entity->setAccess(['foo', 'bar', 'baz'], true);
+        $this->assertTrue($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
+        $this->assertTrue($entity->isAccessible('baz'));
 
-        $entity->accessible('foo', false);
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
-        $this->assertTrue($entity->accessible('baz'));
+        $entity->setAccess('foo', false);
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
+        $this->assertTrue($entity->isAccessible('baz'));
 
-        $entity->accessible(['foo', 'bar', 'baz'], false);
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertFalse($entity->accessible('bar'));
-        $this->assertFalse($entity->accessible('baz'));
+        $entity->setAccess(['foo', 'bar', 'baz'], false);
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertFalse($entity->isAccessible('bar'));
+        $this->assertFalse($entity->isAccessible('baz'));
     }
 
     /**
@@ -1393,22 +1394,22 @@ class EntityTest extends TestCase
     public function testAccessibleWildcard()
     {
         $entity = new Entity();
-        $entity->accessible(['foo', 'bar', 'baz'], true);
-        $this->assertTrue($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
-        $this->assertTrue($entity->accessible('baz'));
+        $entity->setAccess(['foo', 'bar', 'baz'], true);
+        $this->assertTrue($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
+        $this->assertTrue($entity->isAccessible('baz'));
 
-        $entity->accessible('*', false);
-        $this->assertFalse($entity->accessible('foo'));
-        $this->assertFalse($entity->accessible('bar'));
-        $this->assertFalse($entity->accessible('baz'));
-        $this->assertFalse($entity->accessible('newOne'));
+        $entity->setAccess('*', false);
+        $this->assertFalse($entity->isAccessible('foo'));
+        $this->assertFalse($entity->isAccessible('bar'));
+        $this->assertFalse($entity->isAccessible('baz'));
+        $this->assertFalse($entity->isAccessible('newOne'));
 
-        $entity->accessible('*', true);
-        $this->assertTrue($entity->accessible('foo'));
-        $this->assertTrue($entity->accessible('bar'));
-        $this->assertTrue($entity->accessible('baz'));
-        $this->assertTrue($entity->accessible('newOne2'));
+        $entity->setAccess('*', true);
+        $this->assertTrue($entity->isAccessible('foo'));
+        $this->assertTrue($entity->isAccessible('bar'));
+        $this->assertTrue($entity->isAccessible('baz'));
+        $this->assertTrue($entity->isAccessible('newOne2'));
     }
 
     /**
@@ -1420,14 +1421,14 @@ class EntityTest extends TestCase
     {
         $entity = new Entity(['foo' => 1, 'bar' => 2]);
         $options = ['guard' => true];
-        $entity->accessible('*', false);
-        $entity->accessible('foo', true);
+        $entity->setAccess('*', false);
+        $entity->setAccess('foo', true);
         $entity->set('bar', 3, $options);
         $entity->set('foo', 4, $options);
         $this->assertEquals(2, $entity->get('bar'));
         $this->assertEquals(4, $entity->get('foo'));
 
-        $entity->accessible('bar', true);
+        $entity->setAccess('bar', true);
         $entity->set('bar', 3, $options);
         $this->assertEquals(3, $entity->get('bar'));
     }
@@ -1441,13 +1442,13 @@ class EntityTest extends TestCase
     {
         $entity = new Entity(['foo' => 1, 'bar' => 2]);
         $options = ['guard' => true];
-        $entity->accessible('*', false);
-        $entity->accessible('foo', true);
+        $entity->setAccess('*', false);
+        $entity->setAccess('foo', true);
         $entity->set(['bar' => 3, 'foo' => 4], $options);
         $this->assertEquals(2, $entity->get('bar'));
         $this->assertEquals(4, $entity->get('foo'));
 
-        $entity->accessible('bar', true);
+        $entity->setAccess('bar', true);
         $entity->set(['bar' => 3, 'foo' => 5], $options);
         $this->assertEquals(3, $entity->get('bar'));
         $this->assertEquals(5, $entity->get('foo'));
@@ -1461,8 +1462,8 @@ class EntityTest extends TestCase
     public function testSetWithAccessibleSingleProperty()
     {
         $entity = new Entity(['foo' => 1, 'bar' => 2]);
-        $entity->accessible('*', false);
-        $entity->accessible('title', true);
+        $entity->setAccess('*', false);
+        $entity->setAccess('title', true);
 
         $entity->set(['title' => 'test', 'body' => 'Nope']);
         $this->assertEquals('test', $entity->title);
@@ -1495,13 +1496,13 @@ class EntityTest extends TestCase
     {
         $entity = new Entity(['foo' => 'bar'], ['markClean' => true]);
         $entity->somethingElse = 'value';
-        $entity->accessible('id', false);
-        $entity->accessible('name', true);
-        $entity->virtualProperties(['baz']);
+        $entity->setAccess('id', false);
+        $entity->setAccess('name', true);
+        $entity->setVirtual(['baz']);
         $entity->setDirty('foo', true);
-        $entity->errors('foo', ['An error']);
-        $entity->invalid('foo', 'a value');
-        $entity->source('foos');
+        $entity->setError('foo', ['An error']);
+        $entity->setInvalidField('foo', 'a value');
+        $entity->setSource('foos');
         $result = $entity->__debugInfo();
         $expected = [
             'foo' => 'bar',
@@ -1521,14 +1522,17 @@ class EntityTest extends TestCase
     /**
      * Tests the source method
      *
+     * @group deprecated
      * @return void
      */
     public function testSource()
     {
-        $entity = new Entity();
-        $this->assertNull($entity->source());
-        $entity->source('foos');
-        $this->assertEquals('foos', $entity->source());
+        $this->deprecated(function () {
+            $entity = new Entity();
+            $this->assertNull($entity->source());
+            $entity->source('foos');
+            $this->assertEquals('foos', $entity->source());
+        });
     }
 
     /**
@@ -1590,14 +1594,40 @@ class EntityTest extends TestCase
         );
 
         $this->assertFalse($entity->isNew());
-        $this->assertFalse($entity->dirty());
+        $this->assertFalse($entity->isDirty());
 
         $cloned = clone $entity;
         $cloned->isNew(true);
 
-        $this->assertTrue($cloned->dirty());
-        $this->assertTrue($cloned->dirty('a'));
-        $this->assertTrue($cloned->dirty('b'));
+        $this->assertTrue($cloned->isDirty());
+        $this->assertTrue($cloned->isDirty('a'));
+        $this->assertTrue($cloned->isDirty('b'));
+    }
+
+    /**
+     * Provides empty values
+     *
+     * @group deprecated
+     * @return void
+     */
+    public function testDirtyFromClone()
+    {
+        $this->deprecated(function () {
+            $entity = new Entity(
+                ['a' => 1, 'b' => 2],
+                ['markNew' => false, 'markClean' => true]
+            );
+
+            $this->assertFalse($entity->isNew());
+            $this->assertFalse($entity->dirty());
+
+            $cloned = clone $entity;
+            $cloned->isNew(true);
+
+            $this->assertTrue($cloned->dirty());
+            $this->assertTrue($cloned->dirty('a'));
+            $this->assertTrue($cloned->dirty('b'));
+        });
     }
 
     /**

+ 67 - 67
tests/TestCase/ORM/MarshallerTest.php

@@ -195,7 +195,7 @@ class MarshallerTest extends TestCase
         $this->assertEquals($data, $result->toArray());
         $this->assertTrue($result->isDirty(), 'Should be a dirty entity.');
         $this->assertTrue($result->isNew(), 'Should be new');
-        $this->assertEquals('Articles', $result->source());
+        $this->assertEquals('Articles', $result->getSource());
     }
 
     /**
@@ -401,7 +401,7 @@ class MarshallerTest extends TestCase
             'username' => 'Jenny',
         ]);
         // Make the entity think it is new.
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
         $entity = $marshall->merge($entity, $data, ['associated' => ['Articles']]);
         $this->assertTrue($entity->isDirty('username'));
@@ -1326,7 +1326,7 @@ class MarshallerTest extends TestCase
             'title' => 'Foo',
             'body' => 'My Content'
         ]);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->isNew(false);
         $entity->clean();
         $result = $marshall->merge($entity, $data, []);
@@ -1355,14 +1355,14 @@ class MarshallerTest extends TestCase
             'title' => 'Foo',
             'body' => 'My Content'
         ]);
-        $entity->accessible('*', false);
+        $entity->setAccess('*', false);
         $entity->isNew(false);
         $entity->clean();
         $result = $marshall->merge($entity, $data, ['accessibleFields' => ['body' => true]]);
 
         $this->assertSame($entity, $result);
         $this->assertEquals(['title' => 'Foo', 'body' => 'New content'], $result->toArray());
-        $this->assertTrue($entity->accessible('body'));
+        $this->assertTrue($entity->isAccessible('body'));
     }
 
     /**
@@ -1388,7 +1388,7 @@ class MarshallerTest extends TestCase
     {
         $marshall = new Marshaller($this->articles);
         $entity = new Entity();
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $entity = $marshall->merge($entity, ['author_id' => $value]);
@@ -1413,7 +1413,7 @@ class MarshallerTest extends TestCase
             'title' => 'Foo',
             'body' => null
         ]);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->isNew(false);
         $entity->clean();
         $result = $marshall->merge($entity, $data, []);
@@ -1438,8 +1438,8 @@ class MarshallerTest extends TestCase
             'title' => 'Foo',
             'body' => 'My Content'
         ]);
-        $entity->accessible('*', false);
-        $entity->accessible('author_id', true);
+        $entity->setAccess('*', false);
+        $entity->setAccess('author_id', true);
         $entity->isNew(false);
         $entity->clean();
 
@@ -1497,8 +1497,8 @@ class MarshallerTest extends TestCase
            'user' => $user,
         ]);
 
-        $user->accessible('*', true);
-        $article->accessible('*', true);
+        $user->setAccess('*', true);
+        $article->setAccess('*', true);
 
         $data = [
             'title' => 'Chelsea',
@@ -1533,7 +1533,7 @@ class MarshallerTest extends TestCase
             'author_id' => 1,
             'crazy' => true
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
         $result = $marshall->merge($entity, $data, []);
 
@@ -1563,8 +1563,8 @@ class MarshallerTest extends TestCase
             'title' => 'My Title',
             'user' => $user
         ]);
-        $user->accessible('*', true);
-        $entity->accessible('*', true);
+        $user->setAccess('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $data = [
@@ -1595,7 +1595,7 @@ class MarshallerTest extends TestCase
         $entity = new Entity([
             'title' => 'My Title'
         ]);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $data = [
@@ -1634,8 +1634,8 @@ class MarshallerTest extends TestCase
            'user' => $user,
         ]);
 
-        $user->accessible('*', true);
-        $article->accessible('*', true);
+        $user->setAccess('*', true);
+        $article->setAccess('*', true);
 
         $data = [
             'title' => 'Chelsea',
@@ -1668,10 +1668,10 @@ class MarshallerTest extends TestCase
             'comments' => [$comment1, $comment2]
         ]);
 
-        $user->accessible('*', true);
-        $comment1->accessible('*', true);
-        $comment2->accessible('*', true);
-        $entity->accessible('*', true);
+        $user->setAccess('*', true);
+        $comment1->setAccess('*', true);
+        $comment2->setAccess('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $data = [
@@ -1753,7 +1753,7 @@ class MarshallerTest extends TestCase
             'title' => 'Haz moar tags',
             'tags' => ['_ids' => [1, 2, 3]]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $marshall = new Marshaller($this->articles);
@@ -1787,7 +1787,7 @@ class MarshallerTest extends TestCase
             'title' => 'Haz moar tags',
             'tags' => ['_ids' => [1, 2, 3]]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         // Adding a forced join to have another table with the same column names
@@ -1826,7 +1826,7 @@ class MarshallerTest extends TestCase
             'title' => 'Haz moar tags',
             'tags' => ['_ids' => [1, 2, 3]]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->clean();
 
         $marshall = new Marshaller($this->articles);
@@ -1871,7 +1871,7 @@ class MarshallerTest extends TestCase
                 ['id' => 2]
             ]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $marshall = new Marshaller($this->articles);
         $result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);
 
@@ -1902,7 +1902,7 @@ class MarshallerTest extends TestCase
             'title' => 'Haz moar tags',
             'tags' => ['_ids' => '']
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $marshall = new Marshaller($this->articles);
         $result = $marshall->merge($entity, $data, ['associated' => ['Tags']]);
         $this->assertCount(0, $result->tags);
@@ -1946,7 +1946,7 @@ class MarshallerTest extends TestCase
                 ['name' => 'awesome']
             ]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $marshall = new Marshaller($this->articles);
         $result = $marshall->merge($entity, $data, [
             'associated' => ['Tags' => ['onlyIds' => true]]
@@ -1977,7 +1977,7 @@ class MarshallerTest extends TestCase
                 '_ids' => [3]
             ]
         ];
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $marshall = new Marshaller($this->articles);
         $result = $marshall->merge($entity, $data, [
             'associated' => ['Tags' => ['ids' => true]]
@@ -2031,8 +2031,8 @@ class MarshallerTest extends TestCase
 
         $entity = $articles->get(1, ['contain' => 'Tags']);
         // Make only specific fields accessible, but not _joinData.
-        $entity->tags[0]->accessible('*', false);
-        $entity->tags[0]->accessible(['article_id', 'tag_id'], true);
+        $entity->tags[0]->setAccess('*', false);
+        $entity->tags[0]->setAccess(['article_id', 'tag_id'], true);
 
         $data = [
             'title' => 'Haz data',
@@ -2184,7 +2184,7 @@ class MarshallerTest extends TestCase
         $options = ['associated' => ['Tags._joinData']];
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data, $options);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $data = [
             'title' => 'Haz data',
@@ -2250,7 +2250,7 @@ class MarshallerTest extends TestCase
         $options = ['associated' => ['Tags._joinData.Users']];
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data, $options);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $data = [
             'title' => 'Haz data',
@@ -2298,7 +2298,7 @@ class MarshallerTest extends TestCase
     {
         $this->articles->belongsToMany('Tags');
         $entity = $this->articles->get(1, ['contain' => ['Tags']]);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $original = $entity->tags[0]->_joinData;
 
         $this->assertInstanceOf('Cake\ORM\Entity', $entity->tags[0]->_joinData);
@@ -2590,7 +2590,7 @@ class MarshallerTest extends TestCase
 
         $marshall = new Marshaller($this->articles);
         $result = $marshall->one($data, ['associated' => ['Users']]);
-        $this->assertEmpty($result->errors());
+        $this->assertEmpty($result->getErrors());
         $this->assertEquals(1, $result->author_id);
         $this->assertInstanceOf(__NAMESPACE__ . '\OpenEntity', $result->user);
         $this->assertEquals('mark', $result->user->username);
@@ -2622,7 +2622,7 @@ class MarshallerTest extends TestCase
                 'body' => 'My content',
                 'author_id' => 2
             ]);
-            $entity->accessible('*', false);
+            $entity->setAccess('*', false);
             $entity->isNew(false);
             $entity->clean();
             $result = $marshall->merge($entity, $data, ['fieldList' => ['title', 'body']]);
@@ -2635,7 +2635,7 @@ class MarshallerTest extends TestCase
 
             $this->assertSame($entity, $result);
             $this->assertEquals($expected, $result->toArray());
-            $this->assertFalse($entity->accessible('*'));
+            $this->assertFalse($entity->isAccessible('*'));
         });
     }
 
@@ -2657,7 +2657,7 @@ class MarshallerTest extends TestCase
             'body' => 'My content',
             'author_id' => 2
         ]);
-        $entity->accessible('*', false);
+        $entity->setAccess('*', false);
         $entity->isNew(false);
         $entity->clean();
         $result = $marshall->merge($entity, $data, ['fields' => ['title', 'body']]);
@@ -2670,7 +2670,7 @@ class MarshallerTest extends TestCase
 
         $this->assertSame($entity, $result);
         $this->assertEquals($expected, $result->toArray());
-        $this->assertFalse($entity->accessible('*'));
+        $this->assertFalse($entity->isAccessible('*'));
     }
 
     /**
@@ -2773,8 +2773,8 @@ class MarshallerTest extends TestCase
             'tile' => 'My Title',
             'user' => $user
         ]);
-        $user->accessible('*', true);
-        $entity->accessible('*', true);
+        $user->setAccess('*', true);
+        $entity->setAccess('*', true);
 
         $data = [
             'body' => 'My Content',
@@ -2890,7 +2890,7 @@ class MarshallerTest extends TestCase
         $options = ['associated' => ['Tags' => ['associated' => ['_joinData']]]];
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data, $options);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
 
         $data = [
             'title' => 'Haz data',
@@ -2936,7 +2936,7 @@ class MarshallerTest extends TestCase
         $this->articles->getValidator()->requirePresence('thing');
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data);
-        $this->assertNotEmpty($entity->errors('thing'));
+        $this->assertNotEmpty($entity->getError('thing'));
     }
 
     /**
@@ -2985,19 +2985,19 @@ class MarshallerTest extends TestCase
             'validate' => 'custom',
             'associated' => ['Users', 'Comments']
         ]);
-        $this->assertNotEmpty($entity->errors('body'), 'custom was not used');
+        $this->assertNotEmpty($entity->getError('body'), 'custom was not used');
         $this->assertNull($entity->body);
-        $this->assertEmpty($entity->user->errors('thing'));
-        $this->assertNotEmpty($entity->comments[0]->errors('thing'));
+        $this->assertEmpty($entity->user->getError('thing'));
+        $this->assertNotEmpty($entity->comments[0]->getError('thing'));
 
         $entity = (new Marshaller($this->articles))->one($data, [
             'validate' => 'custom',
             'associated' => ['Users' => ['validate' => 'customThing'], 'Comments']
         ]);
-        $this->assertNotEmpty($entity->errors('body'));
+        $this->assertNotEmpty($entity->getError('body'));
         $this->assertNull($entity->body);
-        $this->assertNotEmpty($entity->user->errors('thing'), 'customThing was not used');
-        $this->assertNotEmpty($entity->comments[0]->errors('thing'));
+        $this->assertNotEmpty($entity->user->getError('thing'), 'customThing was not used');
+        $this->assertNotEmpty($entity->comments[0]->getError('thing'));
     }
 
     /**
@@ -3022,14 +3022,14 @@ class MarshallerTest extends TestCase
             'validate' => false,
             'associated' => ['Users']
         ]);
-        $this->assertEmpty($entity->errors('thing'));
-        $this->assertNotEmpty($entity->user->errors('thing'));
+        $this->assertEmpty($entity->getError('thing'));
+        $this->assertNotEmpty($entity->user->getError('thing'));
 
         $entity = (new Marshaller($this->articles))->one($data, [
             'associated' => ['Users' => ['validate' => false]]
         ]);
-        $this->assertNotEmpty($entity->errors('thing'));
-        $this->assertEmpty($entity->user->errors('thing'));
+        $this->assertNotEmpty($entity->getError('thing'));
+        $this->assertEmpty($entity->user->getError('thing'));
     }
 
     /**
@@ -3048,7 +3048,7 @@ class MarshallerTest extends TestCase
         $validator->requirePresence('thing');
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data, ['validate' => $validator]);
-        $this->assertNotEmpty($entity->errors('thing'));
+        $this->assertNotEmpty($entity->getError('thing'));
     }
 
     /**
@@ -3065,9 +3065,9 @@ class MarshallerTest extends TestCase
         $validator = (new Validator)->add('number', 'numeric', ['rule' => 'numeric']);
         $marshall = new Marshaller($this->articles);
         $entity = $marshall->one($data, ['validate' => $validator]);
-        $this->assertNotEmpty($entity->errors('number'));
+        $this->assertNotEmpty($entity->getError('number'));
         $this->assertNull($entity->number);
-        $this->assertSame(['number' => 'bar'], $entity->invalid());
+        $this->assertSame(['number' => 'bar'], $entity->getInvalid());
     }
 
     /**
@@ -3088,9 +3088,9 @@ class MarshallerTest extends TestCase
             'body' => 'My Content',
             'author_id' => 1
         ]);
-        $this->assertEmpty($entity->invalid());
+        $this->assertEmpty($entity->getInvalid());
 
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->isNew(false);
         $entity->clean();
 
@@ -3105,14 +3105,14 @@ class MarshallerTest extends TestCase
 
         $this->assertSame($expected, $result);
         $this->assertSame(1, $result->author_id);
-        $this->assertNotEmpty($result->errors('thing'));
-        $this->assertEmpty($result->errors('id'));
+        $this->assertNotEmpty($result->getError('thing'));
+        $this->assertEmpty($result->getError('id'));
 
         $this->articles->getValidator()->requirePresence('thing', 'create');
         $result = $marshall->merge($entity, $data, []);
 
-        $this->assertEmpty($result->errors('thing'));
-        $this->assertSame(['author_id' => 'foo'], $result->invalid());
+        $this->assertEmpty($result->getError('thing'));
+        $this->assertSame(['author_id' => 'foo'], $result->getInvalid());
     }
 
     /**
@@ -3132,7 +3132,7 @@ class MarshallerTest extends TestCase
             'body' => 'My Content',
             'author_id' => 1
         ]);
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->isNew(true);
         $entity->clean();
 
@@ -3143,14 +3143,14 @@ class MarshallerTest extends TestCase
         $expected = clone $entity;
         $result = $marshall->merge($expected, $data, []);
 
-        $this->assertEmpty($result->errors('author_id'));
-        $this->assertEmpty($result->errors('thing'));
+        $this->assertEmpty($result->getError('author_id'));
+        $this->assertEmpty($result->getError('thing'));
 
         $entity->clean();
         $entity->isNew(false);
         $result = $marshall->merge($entity, $data, []);
-        $this->assertNotEmpty($result->errors('author_id'));
-        $this->assertNotEmpty($result->errors('thing'));
+        $this->assertNotEmpty($result->getError('author_id'));
+        $this->assertNotEmpty($result->getError('thing'));
     }
 
     /**
@@ -3183,7 +3183,7 @@ class MarshallerTest extends TestCase
         $result = $marshall->merge($entity, $data, []);
 
         $this->assertSame($entity, $result);
-        $this->assertEmpty($result->errors());
+        $this->assertEmpty($result->getErrors());
         $this->assertTrue($result->isDirty('_translations'));
 
         $translations = $result->get('_translations');

+ 2 - 2
tests/TestCase/ORM/QueryTest.php

@@ -2563,11 +2563,11 @@ class QueryTest extends TestCase
         $table = TableRegistry::get('authors');
         $table->hasMany('articles');
         $query = $table->find()->contain(['articles' => function ($q) {
-            $this->assertTrue($q->eagerLoaded());
+            $this->assertTrue($q->isEagerLoaded());
 
             return $q;
         }]);
-        $this->assertFalse($query->eagerLoaded());
+        $this->assertFalse($query->isEagerLoaded());
 
         $table->getEventManager()->on('Model.beforeFind', function ($e, $q, $o, $primary) {
             $this->assertTrue($primary);

+ 5 - 5
tests/TestCase/ORM/ResultSetTest.php

@@ -141,7 +141,7 @@ class ResultSetTest extends TestCase
         foreach ($results as $i => $row) {
             $expected = new Entity($this->fixtureData[$i]);
             $expected->isNew(false);
-            $expected->source($this->table->getAlias());
+            $expected->setSource($this->table->getAlias());
             $expected->clean();
             $this->assertEquals($expected, $row, "Row $i does not match");
         }
@@ -390,14 +390,14 @@ class ResultSetTest extends TestCase
             'foreignKey' => 'user_id'
         ]);
         $result = $comments->find()->contain(['Authors'])->first();
-        $this->assertEquals('TestPlugin.Comments', $result->source());
-        $this->assertEquals('TestPlugin.Authors', $result->author->source());
+        $this->assertEquals('TestPlugin.Comments', $result->getSource());
+        $this->assertEquals('TestPlugin.Authors', $result->author->getSource());
 
         $result = $comments->find()->matching('Authors', function ($q) {
             return $q->where(['Authors.id' => 1]);
         })->first();
-        $this->assertEquals('TestPlugin.Comments', $result->source());
-        $this->assertEquals('TestPlugin.Authors', $result->_matchingData['Authors']->source());
+        $this->assertEquals('TestPlugin.Comments', $result->getSource());
+        $this->assertEquals('TestPlugin.Authors', $result->_matchingData['Authors']->getSource());
     }
 
     /**

+ 32 - 32
tests/TestCase/ORM/RulesCheckerIntegrationTest.php

@@ -81,8 +81,8 @@ class RulesCheckerIntegrationTest extends TestCase
         $this->assertTrue($entity->isNew());
         $this->assertTrue($entity->author->isNew());
         $this->assertNull($entity->get('author_id'));
-        $this->assertNotEmpty($entity->author->errors('name'));
-        $this->assertEquals(['This is an error'], $entity->author->errors('name'));
+        $this->assertNotEmpty($entity->author->getError('name'));
+        $this->assertEquals(['This is an error'], $entity->author->getError('name'));
     }
 
     /**
@@ -120,8 +120,8 @@ class RulesCheckerIntegrationTest extends TestCase
         $this->assertNull($entity->article->id);
         $this->assertNull($entity->article->get('author_id'));
         $this->assertFalse($entity->article->isDirty('author_id'));
-        $this->assertNotEmpty($entity->article->errors('title'));
-        $this->assertSame('A Title', $entity->article->invalid('title'));
+        $this->assertNotEmpty($entity->article->getError('title'));
+        $this->assertSame('A Title', $entity->article->getInvalidField('title'));
     }
 
     /**
@@ -169,8 +169,8 @@ class RulesCheckerIntegrationTest extends TestCase
         $this->assertNull($entity->articles[1]->id);
         $this->assertNull($entity->articles[0]->author_id);
         $this->assertNull($entity->articles[1]->author_id);
-        $this->assertEmpty($entity->articles[0]->errors());
-        $this->assertNotEmpty($entity->articles[1]->errors());
+        $this->assertEmpty($entity->articles[0]->getErrors());
+        $this->assertNotEmpty($entity->articles[1]->getErrors());
     }
 
     /**
@@ -215,7 +215,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $this->assertFalse($entity->articles[1]->isNew());
         $this->assertEquals(4, $entity->articles[1]->id);
         $this->assertNull($entity->articles[0]->id);
-        $this->assertNotEmpty($entity->articles[0]->errors('title'));
+        $this->assertNotEmpty($entity->articles[0]->getError('title'));
     }
 
     /**
@@ -321,7 +321,7 @@ class RulesCheckerIntegrationTest extends TestCase
         );
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['ruleName' => 'invalid'], $entity->errors('name'));
+        $this->assertEquals(['ruleName' => 'invalid'], $entity->getError('name'));
     }
 
     /**
@@ -342,10 +342,10 @@ class RulesCheckerIntegrationTest extends TestCase
 
         $this->assertEquals(
             ['_isUnique' => 'This value is already in use'],
-            $entity->errors('title'),
+            $entity->getError('title'),
             'Provided field should have errors'
         );
-        $this->assertEmpty($entity->errors('name'), 'Errors should not apply to original field.');
+        $this->assertEmpty($entity->getError('name'), 'Errors should not apply to original field.');
     }
 
     /**
@@ -365,7 +365,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->isUnique(['name']));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_isUnique' => 'This value is already in use'], $entity->errors('name'));
+        $this->assertEquals(['_isUnique' => 'This value is already in use'], $entity->getError('name'));
 
         $entity->name = 'jose';
         $this->assertSame($entity, $table->save($entity));
@@ -393,7 +393,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->isUnique(['title', 'author_id'], 'Nope'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['title' => ['_isUnique' => 'Nope']], $entity->errors());
+        $this->assertEquals(['title' => ['_isUnique' => 'Nope']], $entity->getErrors());
 
         $entity->clean();
         $entity->author_id = 2;
@@ -422,7 +422,7 @@ class RulesCheckerIntegrationTest extends TestCase
         ]));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_isUnique' => 'All fields are required'], $entity->errors('author_id'));
+        $this->assertEquals(['_isUnique' => 'All fields are required'], $entity->getError('author_id'));
 
         $entity->author_id = 11;
         $this->assertSame($entity, $table->save($entity));
@@ -454,7 +454,7 @@ class RulesCheckerIntegrationTest extends TestCase
         ]));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['author_id' => ['_isUnique' => 'Nope']], $entity->errors());
+        $this->assertEquals(['author_id' => ['_isUnique' => 'Nope']], $entity->getErrors());
 
         $entity->clean();
         $entity->article_id = 10;
@@ -508,7 +508,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn('author_id', 'Authors'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->errors('author_id'));
+        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->getError('author_id'));
     }
 
     /**
@@ -531,10 +531,10 @@ class RulesCheckerIntegrationTest extends TestCase
 
         $this->assertEquals(
             ['_existsIn' => 'This value does not exist'],
-            $entity->errors('other'),
+            $entity->getError('other'),
             'Provided field should have errors'
         );
-        $this->assertEmpty($entity->errors('author_id'), 'Errors should not apply to original field.');
+        $this->assertEmpty($entity->getError('author_id'), 'Errors should not apply to original field.');
     }
 
     /**
@@ -555,7 +555,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn('author_id', TableRegistry::get('Authors'), 'Nope'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_existsIn' => 'Nope'], $entity->errors('author_id'));
+        $this->assertEquals(['_existsIn' => 'Nope'], $entity->getError('author_id'));
     }
 
     /**
@@ -576,7 +576,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn('author_id', 'Authors'));
 
         $this->assertEquals($entity, $table->save($entity));
-        $this->assertEquals([], $entity->errors('author_id'));
+        $this->assertEquals([], $entity->getError('author_id'));
     }
 
     /**
@@ -600,7 +600,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules = $table->rulesChecker();
         $rules->add($rules->existsIn('parent_id', 'Categories'));
         $this->assertTrue($table->checkRules($entity, RulesChecker::CREATE));
-        $this->assertEmpty($entity->errors('parent_id'));
+        $this->assertEmpty($entity->getError('parent_id'));
     }
 
     /**
@@ -623,7 +623,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn('title', 'Authors'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertNotEmpty($entity->errors('title'));
+        $this->assertNotEmpty($entity->getError('title'));
 
         $entity->clean();
         $entity->title = 'larry';
@@ -818,7 +818,7 @@ class RulesCheckerIntegrationTest extends TestCase
         });
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_isUnique' => 'This value is already in use'], $entity->errors('author_id'));
+        $this->assertEquals(['_isUnique' => 'This value is already in use'], $entity->getError('author_id'));
     }
 
     /**
@@ -864,7 +864,7 @@ class RulesCheckerIntegrationTest extends TestCase
         });
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->errors('author_id'));
+        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->getError('author_id'));
     }
 
     /**
@@ -885,7 +885,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn(['author_id'], 'Authors'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->errors('author_id'));
+        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->getError('author_id'));
     }
 
     /**
@@ -977,7 +977,7 @@ class RulesCheckerIntegrationTest extends TestCase
             'message' => 'Niente'
         ]));
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['author_id' => ['_existsIn' => 'Niente']], $entity->errors());
+        $this->assertEquals(['author_id' => ['_existsIn' => 'Niente']], $entity->getErrors());
     }
 
     /**
@@ -1134,7 +1134,7 @@ class RulesCheckerIntegrationTest extends TestCase
             'allowNullableNulls' => true,
             'message' => 'will error']));
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->errors());
+        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->getErrors());
     }
 
     /**
@@ -1159,7 +1159,7 @@ class RulesCheckerIntegrationTest extends TestCase
             'allowNullableNulls' => true,
             'message' => 'will error']));
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->errors());
+        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->getErrors());
     }
 
     /**
@@ -1184,7 +1184,7 @@ class RulesCheckerIntegrationTest extends TestCase
             'allowNullableNulls' => true,
             'message' => 'will error']));
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->errors());
+        $this->assertEquals(['author_id' => ['_existsIn' => 'will error']], $entity->getErrors());
     }
 
     /**
@@ -1269,7 +1269,7 @@ class RulesCheckerIntegrationTest extends TestCase
         }, ['errorField' => 'name']);
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['So much nope'], $entity->errors('name'));
+        $this->assertEquals(['So much nope'], $entity->getError('name'));
     }
 
     /**
@@ -1291,7 +1291,7 @@ class RulesCheckerIntegrationTest extends TestCase
         });
 
         $this->assertFalse($table->save($entity));
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
     }
 
     /**
@@ -1356,7 +1356,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->existsIn('author_id', 'Authors'));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->errors('author_id'));
+        $this->assertEquals(['_existsIn' => 'This value does not exist'], $entity->getError('author_id'));
     }
 
     /**
@@ -1388,7 +1388,7 @@ class RulesCheckerIntegrationTest extends TestCase
         $rules->add($rules->validCount('tags', 3));
 
         $this->assertFalse($table->save($entity));
-        $this->assertEquals($entity->errors(), [
+        $this->assertEquals($entity->getErrors(), [
             'tags' => [
                 '_validCount' => 'The count does not match >3'
             ]

+ 31 - 13
tests/TestCase/ORM/TableTest.php

@@ -3035,7 +3035,7 @@ class TableTest extends TestCase
         $table = TableRegistry::get('Articles');
         $entity = $table->get(1);
 
-        $entity->accessible('*', true);
+        $entity->setAccess('*', true);
         $entity->set($entity->toArray());
         $this->assertSame($entity, $table->save($entity));
     }
@@ -3117,7 +3117,7 @@ class TableTest extends TestCase
             new Entity(['name' => 'mark']),
             new Entity(['name' => 'jose'])
         ];
-        $entities[1]->errors(['name' => ['message']]);
+        $entities[1]->setErrors(['name' => ['message']]);
         $result = $table->saveMany($entities);
 
         $this->assertFalse($result);
@@ -3611,8 +3611,8 @@ class TableTest extends TestCase
         $existingAuthor = $table->find()->first();
         $newAuthor = $table->newEntity();
 
-        $this->assertEquals('TestPlugin.Authors', $existingAuthor->source());
-        $this->assertEquals('TestPlugin.Authors', $newAuthor->source());
+        $this->assertEquals('TestPlugin.Authors', $existingAuthor->getSource());
+        $this->assertEquals('TestPlugin.Authors', $newAuthor->getSource());
     }
 
     /**
@@ -3626,11 +3626,11 @@ class TableTest extends TestCase
         $table = TableRegistry::get('Articles');
         $validator = $table->getValidator()->requirePresence('title');
         $entity = $table->newEntity([]);
-        $errors = $entity->errors();
+        $errors = $entity->getErrors();
         $this->assertNotEmpty($errors['title']);
 
         $entity = $table->newEntity();
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
     }
 
     /**
@@ -6334,16 +6334,34 @@ class TableTest extends TestCase
     /**
      * Tests that calling newEntity() on a table sets the right source alias
      *
+     * @group deprecated
      * @return void
      */
     public function testEntitySource()
     {
+        $this->deprecated(function () {
+            $table = TableRegistry::get('Articles');
+            $this->assertEquals('Articles', $table->newEntity()->source());
+
+            Plugin::load('TestPlugin');
+            $table = TableRegistry::get('TestPlugin.Comments');
+            $this->assertEquals('TestPlugin.Comments', $table->newEntity()->source());
+        });
+    }
+
+    /**
+     * Tests that calling newEntity() on a table sets the right source alias
+     *
+     * @return void
+     */
+    public function testSetEntitySource()
+    {
         $table = TableRegistry::get('Articles');
-        $this->assertEquals('Articles', $table->newEntity()->source());
+        $this->assertEquals('Articles', $table->newEntity()->getSource());
 
         Plugin::load('TestPlugin');
         $table = TableRegistry::get('TestPlugin.Comments');
-        $this->assertEquals('TestPlugin.Comments', $table->newEntity()->source());
+        $this->assertEquals('TestPlugin.Comments', $table->newEntity()->getSource());
     }
 
     /**
@@ -6498,20 +6516,20 @@ class TableTest extends TestCase
         $entity = $table->newEntity(['title' => 'mark']);
 
         $entity->setDirty('title', true);
-        $entity->invalid('title', 'albert');
+        $entity->setInvalidField('title', 'albert');
 
-        $this->assertNotEmpty($entity->errors());
+        $this->assertNotEmpty($entity->getErrors());
         $this->assertTrue($entity->isDirty());
-        $this->assertEquals(['title' => 'albert'], $entity->invalid());
+        $this->assertEquals(['title' => 'albert'], $entity->getInvalid());
 
         $entity->title = 'alex';
         $this->assertSame($entity->getOriginal('title'), 'mark');
 
         $entity->clean();
 
-        $this->assertEmpty($entity->errors());
+        $this->assertEmpty($entity->getErrors());
         $this->assertFalse($entity->isDirty());
-        $this->assertEquals([], $entity->invalid());
+        $this->assertEquals([], $entity->getInvalid());
         $this->assertSame($entity->getOriginal('title'), 'alex');
     }
 

+ 18 - 18
tests/TestCase/View/Form/EntityContextTest.php

@@ -189,7 +189,7 @@ class EntityContextTest extends TestCase
     public function testTableFromEntitySource()
     {
         $entity = new Entity();
-        $entity->source('Articles');
+        $entity->setSource('Articles');
         $context = new EntityContext($this->request, [
             'entity' => $entity,
         ]);
@@ -230,7 +230,7 @@ class EntityContextTest extends TestCase
             'title' => 'Test entity',
             'body' => 'Something new'
         ]);
-        $row->errors('title', ['Title is required.']);
+        $row->setError('title', ['Title is required.']);
 
         $context = new EntityContext($this->request, [
             'entity' => $row,
@@ -240,7 +240,7 @@ class EntityContextTest extends TestCase
         $this->assertEquals($row->title, $result);
 
         $result = $context->error('title');
-        $this->assertEquals($row->errors('title'), $result);
+        $this->assertEquals($row->getError('title'), $result);
         $this->assertTrue($context->hasError('title'));
     }
 
@@ -275,14 +275,14 @@ class EntityContextTest extends TestCase
             'body' => 'Stuff',
             'user' => new Entity(['username' => 'mark'])
         ]);
-        $one->errors('title', 'Required field');
+        $one->setError('title', 'Required field');
 
         $two = new Article([
             'title' => 'Second post',
             'body' => 'Some text',
             'user' => new Entity(['username' => 'jose'])
         ]);
-        $two->errors('body', 'Not long enough');
+        $two->setError('body', 'Not long enough');
 
         return [
             'array' => [[$one, $two]],
@@ -1108,9 +1108,9 @@ class EntityContextTest extends TestCase
             'title' => 'My title',
             'user' => new Entity(['username' => 'Mark']),
         ]);
-        $row->errors('title', []);
-        $row->errors('body', 'Gotta have one');
-        $row->errors('user_id', ['Required field']);
+        $row->setError('title', []);
+        $row->setError('body', 'Gotta have one');
+        $row->setError('user_id', ['Required field']);
         $context = new EntityContext($this->request, [
             'entity' => $row,
             'table' => 'Articles',
@@ -1135,9 +1135,9 @@ class EntityContextTest extends TestCase
             'title' => 'My title',
             'user' => new Entity(['username' => 'Mark']),
         ]);
-        $row->errors('title', []);
-        $row->errors('body', 'Gotta have one');
-        $row->user->errors('username', ['Required']);
+        $row->setError('title', []);
+        $row->setError('body', 'Gotta have one');
+        $row->user->setError('username', ['Required']);
         $context = new EntityContext($this->request, [
             'entity' => $row,
             'table' => 'Articles',
@@ -1161,11 +1161,11 @@ class EntityContextTest extends TestCase
             'title' => 'My title',
             'user' => new Entity(['username' => 'Mark']),
         ]);
-        $row->errors('title', []);
-        $row->errors('body', 'Gotta have one');
-        $row->errors('user_id', ['Required field']);
+        $row->setError('title', []);
+        $row->setError('body', 'Gotta have one');
+        $row->setError('user_id', ['Required field']);
 
-        $row->user->errors('username', ['Required']);
+        $row->user->setError('username', ['Required']);
 
         $context = new EntityContext($this->request, [
             'entity' => $row,
@@ -1198,8 +1198,8 @@ class EntityContextTest extends TestCase
                 new Entity(['comment' => 'Second comment']),
             ]
         ]);
-        $row->comments[0]->errors('comment', ['Is required']);
-        $row->comments[0]->errors('article_id', ['Is required']);
+        $row->comments[0]->setError('comment', ['Is required']);
+        $row->comments[0]->setError('article_id', ['Is required']);
 
         $context = new EntityContext($this->request, [
             'entity' => $row,
@@ -1235,7 +1235,7 @@ class EntityContextTest extends TestCase
                 ])
             ],
         ]);
-        $row->tags[0]->_joinData->errors('tag_id', ['Is required']);
+        $row->tags[0]->_joinData->setError('tag_id', ['Is required']);
 
         $context = new EntityContext($this->request, [
             'entity' => $row,

+ 9 - 9
tests/TestCase/View/Helper/FormHelperTest.php

@@ -2777,7 +2777,7 @@ class FormHelperTest extends TestCase
     public function testFormValidationAssociated()
     {
         $nested = new Entity(['foo' => 'bar']);
-        $nested->errors('foo', ['not a valid bar']);
+        $nested->setError('foo', ['not a valid bar']);
         $entity = new Entity(['nested' => $nested]);
         $this->Form->create($entity, ['context' => ['table' => 'Articles']]);
 
@@ -2797,7 +2797,7 @@ class FormHelperTest extends TestCase
         $inner = new Entity(['bar' => 'baz']);
         $nested = new Entity(['foo' => $inner]);
         $entity = new Entity(['nested' => $nested]);
-        $inner->errors('bar', ['not a valid one']);
+        $inner->setError('bar', ['not a valid one']);
         $this->Form->create($entity, ['context' => ['table' => 'Articles']]);
         $result = $this->Form->error('nested.foo.bar');
         $this->assertEquals('<div class="error-message">not a valid one</div>', $result);
@@ -2818,10 +2818,10 @@ class FormHelperTest extends TestCase
             'className' => __NAMESPACE__ . '\ContactsTable'
         ]);
         $one->set('email', '');
-        $one->errors('email', ['invalid email']);
+        $one->setError('email', ['invalid email']);
 
         $two->set('name', '');
-        $two->errors('name', ['This is wrong']);
+        $two->setError('name', ['This is wrong']);
         $this->Form->create([$one, $two], ['context' => ['table' => 'Contacts']]);
 
         $result = $this->Form->control('0.email');
@@ -3042,7 +3042,7 @@ class FormHelperTest extends TestCase
 
         $this->Form->request->data = [];
 
-        $entity->errors('field', 'Badness!');
+        $entity->setError('field', 'Badness!');
         $this->Form->create($entity, ['context' => ['table' => 'Contacts']]);
         $result = $this->Form->control('field');
         $expected = [
@@ -3081,7 +3081,7 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        $entity->errors('field', ['minLength'], true);
+        $entity->setError('field', ['minLength'], true);
         $result = $this->Form->control('field', [
             'error' => [
                 'minLength' => 'Le login doit contenir au moins 2 caractères',
@@ -3101,7 +3101,7 @@ class FormHelperTest extends TestCase
         ];
         $this->assertHtml($expected, $result);
 
-        $entity->errors('field', ['maxLength'], true);
+        $entity->setError('field', ['maxLength'], true);
         $result = $this->Form->control('field', [
             'error' => [
                 'minLength' => 'Le login doit contenir au moins 2 caractères',
@@ -5359,7 +5359,7 @@ class FormHelperTest extends TestCase
         $this->View->viewVars['spacecraft'] = $spacecraft;
 
         $article = new Article();
-        $article->errors('spacecraft', ['Invalid']);
+        $article->setError('spacecraft', ['Invalid']);
 
         $this->Form->create($article);
         $result = $this->Form->control('spacecraft._ids');
@@ -8213,7 +8213,7 @@ class FormHelperTest extends TestCase
         //@codingStandardsIgnoreEnd
         $this->assertHtml($expected, $result);
 
-        $comment->errors('comment', ['Not valid']);
+        $comment->setError('comment', ['Not valid']);
         $result = $this->Form->control('0.comments.0.comment');
         //@codingStandardsIgnoreStart
         $expected = [