Skip to content

Conversation

@geoidesic
Copy link
Collaborator

The problem was that e.g. for an empty table, the ->first() call would return null, causing an _getSingleEntity to return null instead of an entity object, which caused an error to be thrown because _extractEntityAssociations expects an entity to be passed in.

See: #108

For when $entities->first() returns null
Return an empty entity if resultSet is empty.
@geoidesic
Copy link
Collaborator Author

@here I don't understand why this is failing – I actually added a test and I didn't add any methods to the main code, just an extra line or two of code. I don't know how to resolve this, so a little help would be appreciated! Thanks in advance.

$this->setReflectionClassInstance($listener);
$result = $this->callProtectedMethod('_getSingleEntity', [$subject], $listener);

$this->assertInstanceOf('Cake\ORM\Entity', $result);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Entity::class instead of a class name string.

Copy link
Member

@dakota dakota left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor request

@dakota dakota merged commit aee7c1f into FriendsOfCake:cake-4.x Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants