use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use OCP\Settings\ISettings;
use OCP\Settings\IManager;
use OCP\Settings\ISection;
/** @var IL10N */
private $l;
+ /** @var IFactory */
+ private $l10nFactory;
+
/** @var IURLGenerator */
private $url;
public function __construct(
ILogger $log,
- IL10N $l10n,
+ IFactory $l10nFactory,
IURLGenerator $url,
IServerContainer $container
) {
$this->log = $log;
- $this->l = $l10n;
+ $this->l10nFactory = $l10nFactory;
$this->url = $url;
$this->container = $container;
}
* @inheritdoc
*/
public function getAdminSections(): array {
+ if ($this->l === null) {
+ $this->l = $this->l10nFactory->get('lib');
+ }
+
// built-in sections
$sections = [
0 => [new Section('overview', $this->l->t('Overview'), 0, $this->url->imagePath('settings', 'admin.svg'))],
* @inheritdoc
*/
public function getPersonalSections(): array {
+ if ($this->l === null) {
+ $this->l = $this->l10nFactory->get('lib');
+ }
+
$sections = [
0 => [new Section('personal-info', $this->l->t('Personal info'), 0, $this->url->imagePath('core', 'actions/info.svg'))],
5 => [new Section('security', $this->l->t('Security'), 0, $this->url->imagePath('settings', 'password.svg'))],
use OCP\ILogger;
use OCP\IServerContainer;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use Test\TestCase;
class ManagerTest extends TestCase {
private $logger;
/** @var IDBConnection|\PHPUnit_Framework_MockObject_MockObject */
private $l10n;
+ /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $l10nFactory;
/** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
private $url;
/** @var IServerContainer|\PHPUnit_Framework_MockObject_MockObject */
$this->logger = $this->createMock(ILogger::class);
$this->l10n = $this->createMock(IL10N::class);
+ $this->l10nFactory = $this->createMock(IFactory::class);
$this->url = $this->createMock(IURLGenerator::class);
$this->container = $this->createMock(IServerContainer::class);
$this->manager = new Manager(
$this->logger,
- $this->l10n,
+ $this->l10nFactory,
$this->url,
$this->container
);
}
public function testGetAdminSections() {
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('get')
+ ->with('lib')
+ ->willReturn($this->l10n);
$this->l10n
->expects($this->any())
->method('t')
}
public function testGetPersonalSections() {
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('get')
+ ->with('lib')
+ ->willReturn($this->l10n);
$this->l10n
->expects($this->any())
->method('t')
}
public function testGetAdminSectionsEmptySection() {
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('get')
+ ->with('lib')
+ ->willReturn($this->l10n);
$this->l10n
->expects($this->any())
->method('t')
}
public function testGetPersonalSectionsEmptySection() {
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('get')
+ ->with('lib')
+ ->willReturn($this->l10n);
$this->l10n
->expects($this->any())
->method('t')
}
public function testSameSectionAsPersonalAndAdmin() {
+ $this->l10nFactory
+ ->expects($this->once())
+ ->method('get')
+ ->with('lib')
+ ->willReturn($this->l10n);
$this->l10n
->expects($this->any())
->method('t')