MainTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Review\Test\Unit\Block\Adminhtml;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  8. class MainTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Review\Block\Adminhtml\Main
  12. */
  13. protected $model;
  14. /**
  15. * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $request;
  18. /**
  19. * @var \Magento\Customer\Api\CustomerRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $customerRepository;
  22. /**
  23. * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject
  24. */
  25. protected $customerViewHelper;
  26. public function testConstruct()
  27. {
  28. $this->customerRepository = $this
  29. ->getMockForAbstractClass(\Magento\Customer\Api\CustomerRepositoryInterface::class);
  30. $this->customerViewHelper = $this->createMock(\Magento\Customer\Helper\View::class);
  31. $dummyCustomer = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\CustomerInterface::class);
  32. $this->customerRepository->expects($this->once())
  33. ->method('getById')
  34. ->with('customer id')
  35. ->will($this->returnValue($dummyCustomer));
  36. $this->customerViewHelper->expects($this->once())
  37. ->method('getCustomerName')
  38. ->with($dummyCustomer)
  39. ->will($this->returnValue(new \Magento\Framework\DataObject()));
  40. $this->request = $this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class);
  41. $this->request->expects($this->at(0))
  42. ->method('getParam')
  43. ->with('customerId', false)
  44. ->will($this->returnValue('customer id'));
  45. $this->request->expects($this->at(1))
  46. ->method('getParam')
  47. ->with('productId', false)
  48. ->will($this->returnValue(false));
  49. $objectManagerHelper = new ObjectManagerHelper($this);
  50. $this->model = $objectManagerHelper->getObject(
  51. \Magento\Review\Block\Adminhtml\Main::class,
  52. [
  53. 'request' => $this->request,
  54. 'customerRepository' => $this->customerRepository,
  55. 'customerViewHelper' => $this->customerViewHelper
  56. ]
  57. );
  58. }
  59. }