WebsiteManagementTest.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\Store\Test\Unit\Model;
  7. class WebsiteManagementTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Store\Model\WebsiteManagement
  11. */
  12. protected $model;
  13. /**
  14. * @var \Magento\Store\Model\ResourceModel\Website\CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $websitesFactoryMock;
  17. protected function setUp()
  18. {
  19. $this->websitesFactoryMock = $this->createPartialMock(
  20. \Magento\Store\Model\ResourceModel\Website\CollectionFactory::class,
  21. ['create']
  22. );
  23. $this->model = new \Magento\Store\Model\WebsiteManagement(
  24. $this->websitesFactoryMock
  25. );
  26. }
  27. public function testGetCount()
  28. {
  29. $websitesMock = $this->createMock(\Magento\Store\Model\ResourceModel\Website\Collection::class);
  30. $this->websitesFactoryMock
  31. ->expects($this->once())
  32. ->method('create')
  33. ->willReturn($websitesMock);
  34. $websitesMock
  35. ->expects($this->once())
  36. ->method('getSize')
  37. ->willReturn('expected');
  38. $this->assertEquals(
  39. 'expected',
  40. $this->model->getCount()
  41. );
  42. }
  43. }