Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileProviderTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class FileProviderTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $model;
16 
20  protected $file;
21 
22  protected function setUp()
23  {
24  $fileFactory = $this->getMockBuilder(\Magento\Theme\Model\ResourceModel\Theme\File\CollectionFactory::class)
25  ->setMethods(['create'])
26  ->disableOriginalConstructor()
27  ->getMock();
28  $this->file = $this->getMockBuilder(\Magento\Theme\Model\ResourceModel\Theme\File\Collection::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31  $fileFactory->expects($this->once())
32  ->method('create')
33  ->willReturn($this->file);
34 
36  $this->model = new FileProvider($fileFactory);
37  }
38 
43  public function testGetItems()
44  {
45  $items = ['item'];
46  $theme = $this->getMockBuilder(\Magento\Framework\View\Design\ThemeInterface::class)->getMock();
47  $filters = ['name' => 'filter'];
48  $this->file->expects($this->once())
49  ->method('addThemeFilter')
50  ->with($theme)
51  ->willReturnSelf();
52  $this->file->expects($this->once())
53  ->method('addFieldToFilter')
54  ->with('name', 'filter')
55  ->willReturnSelf();
56  $this->file->expects($this->once())
57  ->method('setDefaultOrder')
58  ->willReturnSelf();
59  $this->file->expects($this->once())
60  ->method('getItems')
61  ->willReturn($items);
62 
64  $this->assertEquals($items, $this->model->getItems($theme, $filters));
65  }
66 }
$theme
$filters
Definition: uploader.phtml:11
$items