Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StoreManagementTest.php
Go to the documentation of this file.
1 <?php
7 
8 class StoreManagementTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $model;
14 
18  protected $storesFactoryMock;
19 
20  protected function setUp()
21  {
22  $this->storesFactoryMock = $this->createPartialMock(
23  \Magento\Store\Model\ResourceModel\Store\CollectionFactory::class,
24  ['create']
25  );
26  $this->model = new \Magento\Store\Model\StoreManagement(
27  $this->storesFactoryMock
28  );
29  }
30 
31  public function testGetCount()
32  {
33  $storesMock = $this->createMock(\Magento\Store\Model\ResourceModel\Store\Collection::class);
34 
35  $this->storesFactoryMock
36  ->expects($this->once())
37  ->method('create')
38  ->willReturn($storesMock);
39  $storesMock
40  ->expects($this->once())
41  ->method('setWithoutDefaultFilter')
42  ->willReturnSelf();
43  $storesMock
44  ->expects($this->once())
45  ->method('getSize')
46  ->willReturn('expected');
47 
48  $this->assertEquals(
49  'expected',
50  $this->model->getCount()
51  );
52  }
53 }