From b74a6ff0f2ad7e5105960ed4a79b6395a472a752 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Fri, 23 Oct 2015 18:11:01 +0300 Subject: [PATCH] MAGETWO-43793: [github] broken references when viewing admin after initial install #1795 --- .../Magento/Framework/View/Layout/Data/Structure.php | 8 ++++---- .../Framework/View/Layout/ScheduledStructure/Helper.php | 6 +++--- .../View/Test/Unit/Layout/Data/StructureTest.php | 3 +-- .../Test/Unit/Layout/ScheduledStructure/HelperTest.php | 7 +------ 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Layout/Data/Structure.php b/lib/internal/Magento/Framework/View/Layout/Data/Structure.php index 643b2cdf9429f..ee2fe6bd206a8 100644 --- a/lib/internal/Magento/Framework/View/Layout/Data/Structure.php +++ b/lib/internal/Magento/Framework/View/Layout/Data/Structure.php @@ -26,7 +26,7 @@ class Structure extends DataStructure protected $logger; /** - * @var \Magento\Framework\App\State + * @var State */ protected $state; @@ -34,12 +34,12 @@ class Structure extends DataStructure * Constructor * * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\App\State $state + * @param State $state * @param array $elements */ public function __construct( \Psr\Log\LoggerInterface $logger, - \Magento\Framework\App\State $state, + State $state, array $elements = null ) { $this->logger = $logger; @@ -118,7 +118,7 @@ public function reorderChildElement($parentName, $childName, $offsetOrSibling, $ if ($childName !== $sibling) { $siblingParentName = $this->getParentId($sibling); if ($parentName !== $siblingParentName) { - if ($this->state->getMode() == State::MODE_DEVELOPER) { + if ($this->state->getMode() === State::MODE_DEVELOPER) { $this->logger->critical( "Broken reference: the '{$childName}' tries to reorder itself towards '{$sibling}', but " . "their parents are different: '{$parentName}' and '{$siblingParentName}' respectively." diff --git a/lib/internal/Magento/Framework/View/Layout/ScheduledStructure/Helper.php b/lib/internal/Magento/Framework/View/Layout/ScheduledStructure/Helper.php index e433a42056f0c..07d6f688e1550 100644 --- a/lib/internal/Magento/Framework/View/Layout/ScheduledStructure/Helper.php +++ b/lib/internal/Magento/Framework/View/Layout/ScheduledStructure/Helper.php @@ -39,11 +39,11 @@ class Helper /** * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\App\State $state + * @param State $state */ public function __construct( \Psr\Log\LoggerInterface $logger, - \Magento\Framework\App\State $state + State $state ) { $this->logger = $logger; $this->state = $state; @@ -200,7 +200,7 @@ public function scheduleElement( } else { $scheduledStructure->setElementToBrokenParentList($key); - if ($this->state->getMode() == State::MODE_DEVELOPER) { + if ($this->state->getMode() === State::MODE_DEVELOPER) { $this->logger->critical( "Broken reference: the '{$name}' element cannot be added as child to '{$parentName}', " . 'because the latter doesn\'t exist' diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php index da88b71ac3884..f5d47e87b95cd 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Data/StructureTest.php @@ -16,7 +16,7 @@ class StructureTest extends \PHPUnit_Framework_TestCase protected $loggerMock; /** - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject + * @var State|\PHPUnit_Framework_MockObject_MockObject */ protected $stateMock; @@ -63,7 +63,6 @@ public function testReorderChildElementLog($loggerExpects, $stateMode) $this->stateMock->expects($this->once()) ->method('getMode') ->willReturn($stateMode); - $this->loggerMock->expects($loggerExpects) ->method('critical') ->with( diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php index 66bcad039431a..82619fa03d207 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/ScheduledStructure/HelperTest.php @@ -31,7 +31,7 @@ class HelperTest extends \PHPUnit_Framework_TestCase protected $loggerMock; /** - * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject + * @var State|\PHPUnit_Framework_MockObject_MockObject */ protected $stateMock; @@ -173,16 +173,13 @@ public function testScheduleElementLog($loggerExpects, $stateMode) ->method('hasStructureElement') ->with($parentName) ->willReturn(false); - $this->dataStructureMock->expects($this->once()) ->method('hasElement') ->with($parentName) ->willReturn(false); - $this->stateMock->expects($this->once()) ->method('getMode') ->willReturn($stateMode); - $this->loggerMock->expects($loggerExpects) ->method('critical') ->with( @@ -259,7 +256,6 @@ public function testScheduleElement($hasParent, $setAsChild, $toRemoveList, $sib ); $this->scheduledStructureMock->expects($this->any())->method('hasStructureElement')->willReturn(true); $this->scheduledStructureMock->expects($this->once())->method('setElement')->with($key, [$block, $data]); - $this->dataStructureMock->expects($this->once())->method('createElement')->with($key, ['type' => $block]); $this->dataStructureMock->expects($this->once()) ->method('hasElement') @@ -269,7 +265,6 @@ public function testScheduleElement($hasParent, $setAsChild, $toRemoveList, $sib ->method('setAsChild') ->with($key, $parentName, $alias) ->willReturn(true); - $this->scheduledStructureMock->expects($this->exactly($toRemoveList)) ->method('setElementToBrokenParentList') ->with($key);