123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\NewRelicReporting\Test\Unit\Model;
- use Magento\NewRelicReporting\Model\Counter;
- use Magento\Catalog\Api\ProductManagementInterface;
- use Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface;
- use Magento\Catalog\Api\CategoryManagementInterface;
- use Magento\Customer\Api\CustomerManagementInterface;
- use Magento\Store\Api\WebsiteManagementInterface;
- use Magento\Store\Api\StoreManagementInterface;
- /**
- * Class CounterTest
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
- */
- class CounterTest extends \PHPUnit\Framework\TestCase
- {
- /**
- * @var \Magento\NewRelicReporting\Model\Counter
- */
- protected $model;
- /**
- * @var ProductManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $productManagement;
- /**
- * @var ConfigurableProductManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $configurableManagement;
- /**
- * @var CategoryManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $categoryManagement;
- /**
- * @var CustomerManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $customerManagement;
- /**
- * @var WebsiteManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $websiteManagement;
- /**
- * @var StoreManagementInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $storeManagement;
- /**
- * Setup
- *
- * @return void
- */
- protected function setUp()
- {
- $this->productManagement = $this->getMockBuilder(\Magento\Catalog\Api\ProductManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configurableManagement = $this
- ->getMockBuilder(\Magento\ConfigurableProduct\Api\ConfigurableProductManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->categoryManagement = $this->getMockBuilder(\Magento\Catalog\Api\CategoryManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->customerManagement = $this->getMockBuilder(\Magento\Customer\Api\CustomerManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->websiteManagement = $this->getMockBuilder(\Magento\Store\Api\WebsiteManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->storeManagement = $this->getMockBuilder(\Magento\Store\Api\StoreManagementInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->model = new Counter(
- $this->productManagement,
- $this->configurableManagement,
- $this->categoryManagement,
- $this->customerManagement,
- $this->websiteManagement,
- $this->storeManagement
- );
- }
- /**
- * Tests all products count will return int
- *
- * @return void
- */
- public function testGetAllProductsCount()
- {
- $this->productManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getAllProductsCount()
- );
- }
- /**
- * Tests all configurable products count will return int
- *
- * @return void
- */
- public function testGetConfigurableCount()
- {
- $this->configurableManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getConfigurableCount()
- );
- }
- /**
- * Tests all active products count will return int
- *
- * @return void
- */
- public function testGetActiveCatalogSize()
- {
- $this->productManagement->expects($this->once())
- ->method('getCount')
- ->with(1)
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getActiveCatalogSize()
- );
- }
- /**
- * Tests categories count will return int
- *
- * @return void
- */
- public function testGetCategoryCount()
- {
- $this->categoryManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getCategoryCount()
- );
- }
- /**
- * Tests customers count will return int
- *
- * @return void
- */
- public function testGetCustomerCount()
- {
- $this->customerManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getCustomerCount()
- );
- }
- /**
- * Tests websites count will return int
- *
- * @return void
- */
- public function testGetWebsiteCount()
- {
- $this->websiteManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getWebsiteCount()
- );
- }
- /**
- * Tests stores count will return int
- *
- * @return void
- */
- public function testGetStoreViewsCount()
- {
- $this->storeManagement->expects($this->once())
- ->method('getCount')
- ->willReturn(1);
- $this->assertInternalType(
- 'int',
- $this->model->getStoreViewsCount()
- );
- }
- }
|