Commit ff6a124b authored by Tino Goratsch's avatar Tino Goratsch

minor code simplifications

parent f6a568ff
......@@ -20,27 +20,27 @@ class StepsTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $containerMock;
protected $containerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $translatorMock;
protected $translatorMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $requestMock;
protected $requestMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $routerMock;
protected $routerMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $eventDispatcherMock;
protected $eventDispatcherMock;
/**
* @var \ACP3\Core\Breadcrumb\Steps
*/
private $steps;
protected $steps;
protected function setUp()
{
......
......@@ -65,13 +65,9 @@ class Steps extends Core\Breadcrumb\Steps
$this->request->getModuleAndController(),
$this->request->getModule()
];
$items = $this->menuItemRepository->getMenuItemsByUri($in);
$cItems = count($items);
// Populate the breadcrumb with internal pages
for ($i = 0; $i < $cItems; ++$i) {
$this->appendFromDB($items[$i]['title'], $items[$i]['uri']);
foreach ($items as $item) {
$this->appendFromDB($item['title'], $item['uri']);
}
}
}
......@@ -115,10 +111,9 @@ class Steps extends Core\Breadcrumb\Steps
$this->breadcrumbCache = $this->stepsFromDb;
if ($this->breadcrumbCache[count($this->breadcrumbCache) - 1]['uri'] === $this->steps[0]['uri']) {
$cStepsFromModules = count($this->steps);
for ($i = 1; $i < $cStepsFromModules; ++$i) {
$this->breadcrumbCache[] = $this->steps[$i];
}
$steps = $this->steps;
unset($steps[0]);
$this->breadcrumbCache = array_merge($this->breadcrumbCache, $steps);
}
}
}
......
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\Menus\Test\Core\Breadcrumb;
use ACP3\Modules\ACP3\Menus\Core\Breadcrumb\Steps;
use ACP3\Modules\ACP3\Menus\Model\MenuItemRepository;
class StepsTest extends \ACP3\Core\Test\Breadcrumb\StepsTest
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $menuItemRepositoryMock;
protected function setUp()
{
$this->initializeMockObjects();
$this->steps = new Steps(
$this->containerMock,
$this->translatorMock,
$this->requestMock,
$this->routerMock,
$this->eventDispatcherMock,
$this->menuItemRepositoryMock
);
}
protected function initializeMockObjects()
{
parent::initializeMockObjects();
$this->menuItemRepositoryMock = $this->getMockBuilder(MenuItemRepository::class)
->disableOriginalConstructor()
->getMock();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment