Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CounterTest.php
Go to the documentation of this file.
1 <?php
7 
15 
20 class CounterTest extends \PHPUnit\Framework\TestCase
21 {
25  protected $model;
26 
30  protected $productManagement;
31 
36 
41 
46 
50  protected $websiteManagement;
51 
55  protected $storeManagement;
56 
62  protected function setUp()
63  {
64  $this->productManagement = $this->getMockBuilder(\Magento\Catalog\Api\ProductManagementInterface::class)
65  ->disableOriginalConstructor()
66  ->getMock();
67  $this->configurableManagement = $this
68  ->getMockBuilder(\Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface::class)
69  ->disableOriginalConstructor()
70  ->getMock();
71  $this->categoryManagement = $this->getMockBuilder(\Magento\Catalog\Api\CategoryManagementInterface::class)
72  ->disableOriginalConstructor()
73  ->getMock();
74  $this->customerManagement = $this->getMockBuilder(\Magento\Customer\Api\CustomerManagementInterface::class)
75  ->disableOriginalConstructor()
76  ->getMock();
77  $this->websiteManagement = $this->getMockBuilder(\Magento\Store\Api\WebsiteManagementInterface::class)
78  ->disableOriginalConstructor()
79  ->getMock();
80  $this->storeManagement = $this->getMockBuilder(\Magento\Store\Api\StoreManagementInterface::class)
81  ->disableOriginalConstructor()
82  ->getMock();
83 
84  $this->model = new Counter(
85  $this->productManagement,
86  $this->configurableManagement,
87  $this->categoryManagement,
88  $this->customerManagement,
89  $this->websiteManagement,
90  $this->storeManagement
91  );
92  }
93 
99  public function testGetAllProductsCount()
100  {
101  $this->productManagement->expects($this->once())
102  ->method('getCount')
103  ->willReturn(1);
104 
105  $this->assertInternalType(
106  'int',
107  $this->model->getAllProductsCount()
108  );
109  }
110 
116  public function testGetConfigurableCount()
117  {
118  $this->configurableManagement->expects($this->once())
119  ->method('getCount')
120  ->willReturn(1);
121 
122  $this->assertInternalType(
123  'int',
124  $this->model->getConfigurableCount()
125  );
126  }
127 
133  public function testGetActiveCatalogSize()
134  {
135  $this->productManagement->expects($this->once())
136  ->method('getCount')
137  ->with(1)
138  ->willReturn(1);
139 
140  $this->assertInternalType(
141  'int',
142  $this->model->getActiveCatalogSize()
143  );
144  }
145 
151  public function testGetCategoryCount()
152  {
153  $this->categoryManagement->expects($this->once())
154  ->method('getCount')
155  ->willReturn(1);
156 
157  $this->assertInternalType(
158  'int',
159  $this->model->getCategoryCount()
160  );
161  }
162 
168  public function testGetCustomerCount()
169  {
170  $this->customerManagement->expects($this->once())
171  ->method('getCount')
172  ->willReturn(1);
173 
174  $this->assertInternalType(
175  'int',
176  $this->model->getCustomerCount()
177  );
178  }
179 
185  public function testGetWebsiteCount()
186  {
187  $this->websiteManagement->expects($this->once())
188  ->method('getCount')
189  ->willReturn(1);
190 
191  $this->assertInternalType(
192  'int',
193  $this->model->getWebsiteCount()
194  );
195  }
196 
202  public function testGetStoreViewsCount()
203  {
204  $this->storeManagement->expects($this->once())
205  ->method('getCount')
206  ->willReturn(1);
207 
208  $this->assertInternalType(
209  'int',
210  $this->model->getStoreViewsCount()
211  );
212  }
213 }