DataTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Contact\Helper;
  7. use Magento\TestFramework\Helper\Bootstrap;
  8. /**
  9. * Test for Magento\Contact\Helper\Data
  10. *
  11. * @magentoDataFixture Magento/Customer/_files/customer.php
  12. */
  13. class DataTest extends \PHPUnit\Framework\TestCase
  14. {
  15. /**
  16. * @var Data
  17. */
  18. protected $contactsHelper;
  19. /**
  20. * @var \Magento\Customer\Model\Session
  21. */
  22. protected $customerSession;
  23. /**
  24. * Setup customer data
  25. */
  26. protected function setUp()
  27. {
  28. $customerIdFromFixture = 1;
  29. $this->contactsHelper = Bootstrap::getObjectManager()->create(\Magento\Contact\Helper\Data::class);
  30. $this->customerSession = Bootstrap::getObjectManager()->create(\Magento\Customer\Model\Session::class);
  31. /**
  32. * @var $customerRepository \Magento\Customer\Api\CustomerRepositoryInterface
  33. */
  34. $customerRepository = Bootstrap::getObjectManager()->create(
  35. \Magento\Customer\Api\CustomerRepositoryInterface::class
  36. );
  37. $customerData = $customerRepository->getById($customerIdFromFixture);
  38. $this->customerSession->setCustomerDataObject($customerData);
  39. }
  40. /**
  41. * Verify if username is set in session
  42. */
  43. public function testGetUserName()
  44. {
  45. $this->assertEquals('John Smith', $this->contactsHelper->getUserName());
  46. }
  47. /**
  48. * Verify if user email is set in session
  49. */
  50. public function testGetEmail()
  51. {
  52. $this->assertEquals('customer@example.com', $this->contactsHelper->getUserEmail());
  53. }
  54. }