Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ThemesTest.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Theme\Model\ResourceModel\Theme\CollectionFactory as ThemeCollectionFactory;
11 
15 class ThemesTest extends \PHPUnit\Framework\TestCase
16 {
20  private $model;
21 
25  private $themeCollectionFactoryMock;
26 
30  private $themeCollectionMock;
31 
32  protected function setUp()
33  {
34  $this->themeCollectionMock = $this->createMock(ThemeCollection::class);
35  $this->themeCollectionFactoryMock = $this->createPartialMock(ThemeCollectionFactory::class, ['create']);
36  $this->model = new Themes(
37  $this->themeCollectionFactoryMock
38  );
39  }
40 
41  public function testToOptionArray()
42  {
43  $expectedResult = [
44  1 => 'Theme Label',
45  ];
46  $this->themeCollectionFactoryMock->expects($this->once())
47  ->method('create')
48  ->willReturn($this->themeCollectionMock);
49 
50  $this->themeCollectionMock->expects($this->once())->method('loadRegisteredThemes')->willReturnSelf();
51  $this->themeCollectionMock->expects($this->once())->method('toOptionHash')->willReturn($expectedResult);
52 
53  $this->assertEquals($expectedResult, $this->model->toOptionArray());
54  }
55 }