CustomerManagementTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Test\Unit\Model;
  7. class CustomerManagementTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Customer\Model\CustomerManagement
  11. */
  12. protected $model;
  13. /**
  14. * @var \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $customersFactoryMock;
  17. protected function setUp()
  18. {
  19. $this->customersFactoryMock = $this->createPartialMock(
  20. \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class,
  21. ['create']
  22. );
  23. $this->model = new \Magento\Customer\Model\CustomerManagement(
  24. $this->customersFactoryMock
  25. );
  26. }
  27. public function testGetCount()
  28. {
  29. $customersMock = $this->createMock(\Magento\Customer\Model\ResourceModel\Customer\Collection::class);
  30. $this->customersFactoryMock
  31. ->expects($this->once())
  32. ->method('create')
  33. ->willReturn($customersMock);
  34. $customersMock
  35. ->expects($this->once())
  36. ->method('getSize')
  37. ->willReturn('expected');
  38. $this->assertEquals(
  39. 'expected',
  40. $this->model->getCount()
  41. );
  42. }
  43. }