Skip to content

Commit

Permalink
Merge pull request #590 from raul338/deprecations-related-listener
Browse files Browse the repository at this point in the history
Remove deprecated calls from RelatedModelsListener
  • Loading branch information
ADmad authored Apr 24, 2018
2 parents f34ec3f + 40318c7 commit a516934
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/Listener/RelatedModelsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function publishRelatedModels($action = null, $entity = null)
$controller = $this->_controller();

foreach ($models as $name => $association) {
list(, $associationName) = pluginSplit($association->name());
list(, $associationName) = pluginSplit($association->getName());
$viewVar = Inflector::variable($associationName);
if (array_key_exists($viewVar, $controller->viewVars)) {
continue;
Expand Down Expand Up @@ -196,7 +196,7 @@ public function getAssociatedByType($types = [])
continue;
}

$return[$associationClass->name()] = $associationClass;
$return[$associationClass->getName()] = $associationClass;
}

return $return;
Expand Down Expand Up @@ -224,7 +224,7 @@ public function getAssociatedByName($names)
$association
));
}
$return[$associationClass->name()] = $associationClass;
$return[$associationClass->getName()] = $associationClass;
}

return $return;
Expand Down
9 changes: 4 additions & 5 deletions tests/TestCase/Listener/RelatedModelsListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testGetAssociatedByTypeReturnValue()
$association = $this
->getMockBuilder('\Cake\ORM\Association')
->disableOriginalConstructor()
->setMethods(['type', 'name', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'])
->setMethods(['type', 'getName', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'])
->getMock();

$listener
Expand All @@ -172,7 +172,7 @@ public function testGetAssociatedByTypeReturnValue()
->will($this->returnValue($association));
$association
->expects($this->once())
->method('name')
->method('getName')
->will($this->returnValue('Posts'));
$association
->expects($this->once())
Expand Down Expand Up @@ -212,7 +212,7 @@ public function testGetAssociatedByNameReturnValue()
$association = $this
->getMockBuilder('\Cake\ORM\Association')
->disableOriginalConstructor()
->setMethods(['type', 'name', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'])
->setMethods(['type', 'getName', 'eagerLoader', 'cascadeDelete', 'isOwningSide', 'saveAssociated'])
->getMock();

$listener
Expand All @@ -231,8 +231,7 @@ public function testGetAssociatedByNameReturnValue()
->will($this->returnValue($association));
$association
->expects($this->once())
->method('name')
->with(null)
->method('getName')
->will($this->returnValue('Posts'));

$expected = ['Posts' => $association];
Expand Down

0 comments on commit a516934

Please sign in to comment.