PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/dev/tests/integration/testsuite/Magento/Customer/Block/Adminhtml/Edit/Tab/View/SalesTest.php

https://gitlab.com/crazybutterfly815/magento2
PHP | 127 lines | 64 code | 15 blank | 48 comment | 0 complexity | 0f0885f03c816e18dbfce3353b7443d3 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright © 2016 Magento. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Block\Adminhtml\Edit\Tab\View;
  7. use Magento\Customer\Controller\RegistryConstants;
  8. use Magento\TestFramework\Helper\Bootstrap;
  9. /**
  10. * Class SalesTest
  11. *
  12. * @magentoAppArea adminhtml
  13. */
  14. class SalesTest extends \PHPUnit_Framework_TestCase
  15. {
  16. const MAIN_WEBSITE = 1;
  17. /**
  18. * Sales block under test.
  19. *
  20. * @var Sales
  21. */
  22. private $block;
  23. /**
  24. * Core registry.
  25. *
  26. * @var \Magento\Framework\Registry
  27. */
  28. private $coreRegistry;
  29. /**
  30. * Sales order view Html.
  31. *
  32. * @var string
  33. */
  34. private $html;
  35. /**
  36. * Execute per test initialization.
  37. */
  38. public function setUp()
  39. {
  40. $objectManager = Bootstrap::getObjectManager();
  41. $objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('adminhtml');
  42. $this->coreRegistry = $objectManager->get(\Magento\Framework\Registry::class);
  43. $this->coreRegistry->register(RegistryConstants::CURRENT_CUSTOMER_ID, 1);
  44. $this->block = $objectManager->get(
  45. \Magento\Framework\View\LayoutInterface::class
  46. )->createBlock(
  47. \Magento\Customer\Block\Adminhtml\Edit\Tab\View\Sales::class,
  48. 'sales_' . mt_rand(),
  49. ['coreRegistry' => $this->coreRegistry]
  50. )->setTemplate(
  51. 'tab/view/sales.phtml'
  52. );
  53. $this->html = $this->block->toHtml();
  54. }
  55. /**
  56. * Execute post test cleanup.
  57. */
  58. public function tearDown()
  59. {
  60. $this->coreRegistry->unregister(RegistryConstants::CURRENT_CUSTOMER_ID);
  61. $this->html = '';
  62. }
  63. /**
  64. * Test basic currency formatting on the Main Website.
  65. */
  66. public function testFormatCurrency()
  67. {
  68. $this->assertEquals(
  69. '<span class="price">$10.00</span>',
  70. $this->block->formatCurrency(10.00, self::MAIN_WEBSITE)
  71. );
  72. }
  73. /**
  74. * Verify that the website is not in single store mode.
  75. */
  76. public function testIsSingleStoreMode()
  77. {
  78. $this->assertFalse($this->block->isSingleStoreMode());
  79. }
  80. /**
  81. * Verify sales totals. No sales so there are no totals.
  82. */
  83. public function testGetTotals()
  84. {
  85. $this->assertEquals(
  86. ['lifetime' => 0, 'base_lifetime' => 0, 'base_avgsale' => 0, 'num_orders' => 0],
  87. $this->block->getTotals()->getData()
  88. );
  89. }
  90. /**
  91. * Verify that there are no rows in the sales order grid.
  92. */
  93. public function testGetRows()
  94. {
  95. $this->assertEmpty($this->block->getRows());
  96. }
  97. /**
  98. * Verify that the Main Website has no websites.
  99. */
  100. public function testGetWebsiteCount()
  101. {
  102. $this->assertEquals(0, $this->block->getWebsiteCount(self::MAIN_WEBSITE));
  103. }
  104. /**
  105. * Verify basic content of the sales view Html.
  106. */
  107. public function testToHtml()
  108. {
  109. $this->assertContains('<span class="title">Sales Statistics</span>', $this->html);
  110. $this->assertContains('<strong>All Store Views</strong>', $this->html);
  111. }
  112. }