|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / a / home / dev2.destoffenstraat.com / vendor / magento / framework / Config / Test / Unit / |
Filename | /home/a/home/dev2.destoffenstraat.com/vendor/magento/framework/Config/Test/Unit/ViewFactoryTest.php |
Size | 2.88 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 21-Aug-2025 12:26 |
Last modified | 07-Jan-2021 21:08 |
Last accessed | 23-Aug-2025 07:05 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Framework\Config\Test\Unit;
use Magento\Framework\Config\FileResolver;
use Magento\Framework\Config\View;
use Magento\Framework\Config\ViewFactory;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Design\ThemeInterface;
use Magento\Theme\Model\View\Design;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class ViewFactoryTest extends TestCase
{
const AREA = 'frontend';
/**
* @var ViewFactory
*/
protected $model;
/**
* @var ObjectManagerInterface|MockObject
*/
protected $objectManager;
/**
* @var \Magento\Framework\View\Design\ThemeInterface|MockObject
*/
protected $theme;
/**
* @var View|MockObject
*/
protected $view;
protected function setUp(): void
{
$this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
$this->model = new ViewFactory($this->objectManager);
$this->theme = $this->getMockForAbstractClass(ThemeInterface::class);
$this->view = $this->createMock(View::class);
}
public function testCreate()
{
$this->objectManager->expects($this->once())
->method('create')
->with(View::class, [])
->willReturn($this->view);
$this->assertEquals($this->view, $this->model->create());
}
public function testCreateWithArguments()
{
/** @var Design|MockObject $design */
$design = $this->createMock(Design::class);
$design->expects($this->once())
->method('setDesignTheme')
->with($this->theme, self::AREA);
/** @var FileResolver|MockObject $fileResolver */
$fileResolver = $this->createMock(FileResolver::class);
$valueMap = [
[Design::class, [], $design],
[FileResolver::class, ['designInterface' => $design], $fileResolver],
[View::class, ['fileResolver' => $fileResolver], $this->view],
];
$this->objectManager->expects($this->exactly(3))
->method('create')
->willReturnMap($valueMap);
$this->assertEquals($this->view, $this->model->create($this->getArguments()));
}
public function testCreateException()
{
$this->expectException('Magento\Framework\Exception\LocalizedException');
$this->expectExceptionMessage('wrong theme doesn\'t implement ThemeInterface');
$this->model->create(
[
'themeModel' => 'wrong theme',
'area' => self::AREA
]
);
}
/**
* @return array
*/
protected function getArguments()
{
return [
'themeModel' => $this->theme,
'area' => self::AREA
];
}
}
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Framework\Config\Test\Unit;
use Magento\Framework\Config\FileResolver;
use Magento\Framework\Config\View;
use Magento\Framework\Config\ViewFactory;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\View\Design\ThemeInterface;
use Magento\Theme\Model\View\Design;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class ViewFactoryTest extends TestCase
{
const AREA = 'frontend';
/**
* @var ViewFactory
*/
protected $model;
/**
* @var ObjectManagerInterface|MockObject
*/
protected $objectManager;
/**
* @var \Magento\Framework\View\Design\ThemeInterface|MockObject
*/
protected $theme;
/**
* @var View|MockObject
*/
protected $view;
protected function setUp(): void
{
$this->objectManager = $this->getMockForAbstractClass(ObjectManagerInterface::class);
$this->model = new ViewFactory($this->objectManager);
$this->theme = $this->getMockForAbstractClass(ThemeInterface::class);
$this->view = $this->createMock(View::class);
}
public function testCreate()
{
$this->objectManager->expects($this->once())
->method('create')
->with(View::class, [])
->willReturn($this->view);
$this->assertEquals($this->view, $this->model->create());
}
public function testCreateWithArguments()
{
/** @var Design|MockObject $design */
$design = $this->createMock(Design::class);
$design->expects($this->once())
->method('setDesignTheme')
->with($this->theme, self::AREA);
/** @var FileResolver|MockObject $fileResolver */
$fileResolver = $this->createMock(FileResolver::class);
$valueMap = [
[Design::class, [], $design],
[FileResolver::class, ['designInterface' => $design], $fileResolver],
[View::class, ['fileResolver' => $fileResolver], $this->view],
];
$this->objectManager->expects($this->exactly(3))
->method('create')
->willReturnMap($valueMap);
$this->assertEquals($this->view, $this->model->create($this->getArguments()));
}
public function testCreateException()
{
$this->expectException('Magento\Framework\Exception\LocalizedException');
$this->expectExceptionMessage('wrong theme doesn\'t implement ThemeInterface');
$this->model->create(
[
'themeModel' => 'wrong theme',
'area' => self::AREA
]
);
}
/**
* @return array
*/
protected function getArguments()
{
return [
'themeModel' => $this->theme,
'area' => self::AREA
];
}
}