Browse Source

Fix tests.

mscherer 7 years ago
parent
commit
d708e5b264

+ 2 - 1
tests/TestCase/Controller/Component/PaginatorComponentTest.php

@@ -1426,7 +1426,8 @@ class PaginatorComponentTest extends TestCase
     {
         $model = $this->getMockBuilder(RepositoryInterface::class)
             ->setMethods([
-                'getAlias', 'setAlias', 'setRegistryAlias', 'getRegistryAlias', 'hasField', 'find', 'get', 'query', 'updateAll', 'deleteAll',
+                'getAlias', 'setAlias', 'setRegistryAlias', 'getRegistryAlias', 'hasField',
+                'find', 'get', 'query', 'updateAll', 'deleteAll', 'createEntity',
                 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities',
             ])
             ->getMock();

+ 2 - 1
tests/TestCase/Datasource/PaginatorTest.php

@@ -974,7 +974,8 @@ class PaginatorTest extends TestCase
     {
         $model = $this->getMockBuilder(RepositoryInterface::class)
             ->setMethods([
-                'getAlias', 'setAlias', 'setRegistryAlias', 'getRegistryAlias', 'hasField', 'find', 'get', 'query', 'updateAll', 'deleteAll',
+                'getAlias', 'setAlias', 'setRegistryAlias', 'getRegistryAlias', 'hasField',
+                'find', 'get', 'query', 'updateAll', 'deleteAll', 'createEntity',
                 'exists', 'save', 'delete', 'newEntity', 'newEntities', 'patchEntity', 'patchEntities',
             ])
             ->getMock();

+ 3 - 3
tests/TestCase/ORM/Association/HasManyTest.php

@@ -803,7 +803,7 @@ class HasManyTest extends TestCase
             'saveStrategy' => HasMany::SAVE_APPEND,
         ]);
 
-        $entity = $articles->newEntity();
+        $entity = $articles->createEntity();
         $entity->set('comments', 'oh noes');
 
         $association->saveAssociated($entity);
@@ -842,7 +842,7 @@ class HasManyTest extends TestCase
         $comments = $association->find();
         $this->assertNotEmpty($comments);
 
-        $entity = $articles->newEntity();
+        $entity = $articles->createEntity();
         $entity->set('comments', $value);
 
         $this->assertSame($entity, $association->saveAssociated($entity));
@@ -899,7 +899,7 @@ class HasManyTest extends TestCase
         $comments = $association->find();
         $this->assertNotEmpty($comments);
 
-        $entity = $articles->newEntity();
+        $entity = $articles->createEntity();
         $entity->set('comments', $value);
 
         $this->assertSame($entity, $association->saveAssociated($entity));

+ 2 - 2
tests/TestCase/ORM/Behavior/TranslateBehaviorShadowTableTest.php

@@ -896,7 +896,7 @@ class TranslateBehaviorShadowTableTest extends TranslateBehaviorTest
             ],
         ];
 
-        $article = $table->patchEntity($table->newEntity(), $data);
+        $article = $table->patchEntity($table->createEntity(), $data);
         $result = $table->save($article);
 
         $this->assertNotFalse($result);
@@ -1041,7 +1041,7 @@ class TranslateBehaviorShadowTableTest extends TranslateBehaviorTest
         $translate = $table->behaviors()->get('Translate');
 
         $map = $translate->buildMarshalMap($table->marshaller(), [], []);
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $data = [
             'en' => [
                 'title' => 'English Title',

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

@@ -1342,7 +1342,7 @@ class TranslateBehaviorTest extends TestCase
             ],
         ];
 
-        $article = $table->patchEntity($table->newEntity(), $data);
+        $article = $table->patchEntity($table->createEntity(), $data);
         $result = $table->save($article);
 
         $this->assertNotFalse($result);
@@ -1586,7 +1586,7 @@ class TranslateBehaviorTest extends TestCase
         $translate = $table->behaviors()->get('Translate');
 
         $map = $translate->buildMarshalMap($table->marshaller(), [], []);
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $result = $map['_translations']('garbage', $entity);
         $this->assertNull($result, 'Non-array should not error out.');
         $this->assertEmpty($entity->getErrors());
@@ -1605,7 +1605,7 @@ class TranslateBehaviorTest extends TestCase
         $translate = $table->behaviors()->get('Translate');
 
         $map = $translate->buildMarshalMap($table->marshaller(), [], []);
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $data = [
             'en' => [
                 'title' => 'English Title',
@@ -1641,7 +1641,7 @@ class TranslateBehaviorTest extends TestCase
         $table->setValidator('custom', $validator);
         $translate = $table->behaviors()->get('Translate');
 
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $map = $translate->buildMarshalMap($table->marshaller(), [], []);
         $data = [
             'en' => [
@@ -1679,7 +1679,7 @@ class TranslateBehaviorTest extends TestCase
         ]);
         $translate = $table->behaviors()->get('Translate');
 
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $es = $table->newEntity(['title' => 'Old title', 'body' => 'Old body']);
         $en = $table->newEntity(['title' => 'Old title', 'body' => 'Old body']);
         $entity->set('_translations', [
@@ -1724,7 +1724,7 @@ class TranslateBehaviorTest extends TestCase
         $table->setValidator('custom', $validator);
         $translate = $table->behaviors()->get('Translate');
 
-        $entity = $table->newEntity();
+        $entity = $table->createEntity();
         $es = $table->newEntity(['title' => 'Old title', 'body' => 'Old body']);
         $en = $table->newEntity(['title' => 'Old title', 'body' => 'Old body']);
         $entity->set('_translations', [
@@ -1742,7 +1742,7 @@ class TranslateBehaviorTest extends TestCase
                 'body' => 'Contenido Español',
             ],
         ];
-        $result = $map['_translations']($data, $entity);
+        $map['_translations']($data, $entity);
         $this->assertNotEmpty($entity->getErrors(), 'Needs validation errors.');
         $expected = [
             'title' => [

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

@@ -3104,7 +3104,7 @@ class MarshallerTest extends TestCase
         ];
 
         $marshall = new Marshaller($this->articles);
-        $entity = $this->articles->newEntity();
+        $entity = $this->articles->createEntity();
         $result = $marshall->merge($entity, $data, []);
 
         $this->assertSame($entity, $result);

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

@@ -438,7 +438,7 @@ class QueryRegressionTest extends TestCase
             return $query->contain('Authors');
         });
 
-        $article = $articles->newEntity();
+        $article = $articles->createEntity();
         $article->title = 'Foo';
         $article->body = 'Bar';
         $this->assertSame($article, $articles->save($article));
@@ -454,7 +454,7 @@ class QueryRegressionTest extends TestCase
     {
         $this->loadFixtures('Articles');
         $articles = $this->getTableLocator()->get('Articles');
-        $article = $articles->newEntity();
+        $article = $articles->createEntity();
         $article->title = new QueryExpression("SELECT 'jose'");
         $this->assertSame($article, $articles->save($article));
     }

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

@@ -698,7 +698,7 @@ class EntityContextTest extends TestCase
         $table = $this->getTableLocator()->get('Articles');
         $column = $table->getSchema()->getColumn('title');
         $table->getSchema()->addColumn('title', ['default' => 'default title'] + $column);
-        $row = $table->newEntity();
+        $row = $table->createEntity();
 
         $context = new EntityContext($this->request, [
             'entity' => $row,
@@ -719,7 +719,7 @@ class EntityContextTest extends TestCase
         $associatedTable = $table->hasMany('Comments')->getTarget();
         $column = $associatedTable->getSchema()->getColumn('comment');
         $associatedTable->getSchema()->addColumn('comment', ['default' => 'default comment'] + $column);
-        $row = $table->newEntity();
+        $row = $table->createEntity();
 
         $context = new EntityContext($this->request, [
             'entity' => $row,
@@ -745,7 +745,7 @@ class EntityContextTest extends TestCase
             'default' => 'default join table column value',
             'type' => 'text',
         ]);
-        $row = $table->newEntity();
+        $row = $table->createEntity();
 
         $context = new EntityContext($this->request, [
             'entity' => $row,

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

@@ -3275,7 +3275,7 @@ class FormHelperTest extends TestCase
     {
         $articles = $this->getTableLocator()->get('Articles');
         $articles->getSchema()->addColumn('active', ['type' => 'boolean', 'default' => null]);
-        $article = $articles->newEntity();
+        $article = $articles->createEntity();
 
         $this->Form->create($article);
 
@@ -4368,7 +4368,7 @@ class FormHelperTest extends TestCase
             ['default' => 'default title'] + $title
         );
 
-        $entity = $Articles->newEntity();
+        $entity = $Articles->createEntity();
         $this->Form->create($entity);
 
         // Get default value from schema
@@ -4704,7 +4704,7 @@ class FormHelperTest extends TestCase
             ['default' => '1'] + $title
         );
 
-        $this->Form->create($Articles->newEntity());
+        $this->Form->create($Articles->createEntity());
 
         $result = $this->Form->radio('title', ['option A', 'option B']);
         $expected = [
@@ -5863,7 +5863,7 @@ class FormHelperTest extends TestCase
             ['type' => 'boolean', 'null' => false, 'default' => true]
         );
 
-        $this->Form->create($Articles->newEntity());
+        $this->Form->create($Articles->createEntity());
         $result = $this->Form->checkbox('published', ['hiddenField' => false]);
         $expected = ['input' => ['type' => 'checkbox', 'name' => 'published', 'value' => '1', 'checked' => 'checked']];
         $this->assertHtml($expected, $result);
@@ -8396,7 +8396,7 @@ class FormHelperTest extends TestCase
         $this->View->setRequest($this->View->getRequest()->withQueryParams(['category' => 'sesame-cookies']));
 
         $articles = $this->getTableLocator()->get('Articles');
-        $entity = $articles->newEntity();
+        $entity = $articles->createEntity();
         $this->Form->create($entity);
 
         $this->Form->setValueSources(['query', 'context']);