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