From dc59fbcb84384a014a38bce60593516900caa910 Mon Sep 17 00:00:00 2001 From: Alejandro Ibarra Date: Fri, 15 Jul 2022 10:15:25 +0200 Subject: [PATCH] Fix ModelCommandTest::testBakeEntityWithPlugin() --- tests/TestCase/Command/ModelCommandTest.php | 4 +- .../Model/testBakeEntityWithPlugin.php | 86 +++++++------------ 2 files changed, 32 insertions(+), 58 deletions(-) diff --git a/tests/TestCase/Command/ModelCommandTest.php b/tests/TestCase/Command/ModelCommandTest.php index b989c09f9..9860ce39b 100644 --- a/tests/TestCase/Command/ModelCommandTest.php +++ b/tests/TestCase/Command/ModelCommandTest.php @@ -1765,9 +1765,9 @@ public function testBakeEntityWithPlugin() $this->_loadTestPlugin('BakeTest'); $path = Plugin::path('BakeTest'); - $this->generatedFile = $path . 'src/Model/Table/UsersTable.php'; + $this->generatedFile = $path . 'src/Model/Entity/User.php'; - $this->exec('bake model --no-validation --no-test --no-fixture --no-entity -p BakeTest Users'); + $this->exec('bake model --no-validation --no-test --no-fixture --no-table BakeTest.Users'); $this->assertExitCode(CommandInterface::CODE_SUCCESS); $this->assertFileExists($this->generatedFile); diff --git a/tests/comparisons/Model/testBakeEntityWithPlugin.php b/tests/comparisons/Model/testBakeEntityWithPlugin.php index 15f39a418..c8b295a19 100644 --- a/tests/comparisons/Model/testBakeEntityWithPlugin.php +++ b/tests/comparisons/Model/testBakeEntityWithPlugin.php @@ -1,74 +1,48 @@ */ - public function initialize(array $config): void - { - parent::initialize($config); - - $this->setTable('users'); - $this->setDisplayField('id'); - $this->setPrimaryKey('id'); - - $this->addBehavior('Timestamp'); - - $this->hasMany('Comments', [ - 'foreignKey' => 'user_id', - 'className' => 'BakeTest.Comments', - ]); - $this->hasMany('TodoItems', [ - 'foreignKey' => 'user_id', - 'className' => 'BakeTest.TodoItems', - ]); - } + protected $_accessible = [ + 'username' => true, + 'password' => true, + 'created' => true, + 'updated' => true, + 'comments' => true, + 'todo_items' => true, + ]; /** - * Returns a rules checker object that will be used for validating - * application integrity. + * Fields that are excluded from JSON versions of the entity. * - * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. - * @return \Cake\ORM\RulesChecker + * @var array */ - public function buildRules(RulesChecker $rules): RulesChecker - { - $rules->add($rules->isUnique(['username']), ['errorField' => 'username']); - - return $rules; - } + protected $_hidden = [ + 'password', + ]; }