DataTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Theme\Test\Unit\Model\Theme;
  7. use Magento\Framework\App\Area;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  9. use Magento\Theme\Model\Theme\Data;
  10. class DataTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var Data
  14. */
  15. protected $model;
  16. protected function setUp()
  17. {
  18. $customizationConfig = $this->createMock(\Magento\Theme\Model\Config\Customization::class);
  19. $this->customizationFactory = $this->createPartialMock(
  20. \Magento\Framework\View\Design\Theme\CustomizationFactory::class,
  21. ['create']
  22. );
  23. $this->resourceCollection = $this->createMock(\Magento\Theme\Model\ResourceModel\Theme\Collection::class);
  24. $this->_imageFactory = $this->createPartialMock(
  25. \Magento\Framework\View\Design\Theme\ImageFactory::class,
  26. ['create']
  27. );
  28. $this->themeFactory = $this->createPartialMock(
  29. \Magento\Framework\View\Design\Theme\FlyweightFactory::class,
  30. ['create']
  31. );
  32. $this->domainFactory = $this->createPartialMock(
  33. \Magento\Framework\View\Design\Theme\Domain\Factory::class,
  34. ['create']
  35. );
  36. $this->themeModelFactory = $this->createPartialMock(\Magento\Theme\Model\ThemeFactory::class, ['create']);
  37. $this->validator = $this->createMock(\Magento\Framework\View\Design\Theme\Validator::class);
  38. $this->appState = $this->createMock(\Magento\Framework\App\State::class);
  39. $objectManagerHelper = new ObjectManager($this);
  40. $arguments = $objectManagerHelper->getConstructArguments(
  41. \Magento\Theme\Model\Theme\Data::class,
  42. [
  43. 'customizationFactory' => $this->customizationFactory,
  44. 'customizationConfig' => $customizationConfig,
  45. 'imageFactory' => $this->_imageFactory,
  46. 'resourceCollection' => $this->resourceCollection,
  47. 'themeFactory' => $this->themeFactory,
  48. 'domainFactory' => $this->domainFactory,
  49. 'validator' => $this->validator,
  50. 'appState' => $this->appState,
  51. 'themeModelFactory' => $this->themeModelFactory
  52. ]
  53. );
  54. $this->model = $objectManagerHelper->getObject(\Magento\Theme\Model\Theme\Data::class, $arguments);
  55. }
  56. /**
  57. * @test
  58. * @return void
  59. */
  60. public function testGetArea()
  61. {
  62. $area = Area::AREA_FRONTEND;
  63. $this->model->setArea($area);
  64. $this->assertEquals($area, $this->model->getArea());
  65. }
  66. }