Closed dewalddp closed 7 years ago
I wrote a little test case to show the previous behavior, and it returns true for an empty tags set as well.
This test will fail, and uses the original has()
. Debugging the entity shows an empty set, just like with the lazy loader.
public function testOriginalHas()
{
TableRegistry::clear();
$Articles = TableRegistry::get('Articles');
$Articles->belongsTo('Authors');
$Articles->belongsToMany('Tags');
$this->assertSame('\Cake\ORM\Entity', $Articles->entityClass());
$article = $Articles->get(3, [
'contain' => ['Authors', 'Tags']
]);
$this->assertTrue($article->has('author'));
// this next assertion fails
$this->assertFalse($article->has('tags'));
}
@dewalddp any thoughts on this?
Going to close this for now due to lack of updates.
The
LazyLoadEntityTrait::has()
method behaved differently than the overwrittenEntityTrait::has()
method. The former always returned true if the property exists for a hasMany relationship, even if there were no values. The latter returns true only if there are values.