Skip to content

Fix controller test baking when the table alias differs (3.x) - #1111

Open
dereuromark wants to merge 1 commit into
3.xfrom
fix-test-controller-alias-3.x
Open

dereuromark wants to merge 1 commit into
3.xfrom
fix-test-controller-alias-3.x

Conversation

@dereuromark

Copy link
Copy Markdown
Member

bake test controller crashes when the controller's default table uses an alias that differs from the controller's table name, for example a table calling setAlias() in initialize():

TypeError: Bake\Command\TestCommand::_processModel(): Argument #1 ($subject) must be of type Cake\ORM\Table, null given

_processController() already has the table from fetchTable(), but then looked it up again as a controller property named after the alias. That property only exists when alias and table name match, so the lookup returned null.

The table instance is now passed on directly.

Same fix for 2.x: #1110

Baking a controller test resolved the default table, then read it back
from the controller as a property named after the table's alias. That
only works while the alias equals the controller's table name. With a
custom alias the property lookup returned null and the command died
with a TypeError in _processModel().

Use the table instance that was already resolved.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant