CartTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Test class for \Magento\Checkout\Block\Cart
  8. */
  9. namespace Magento\Checkout\Block;
  10. class CartTest extends \PHPUnit\Framework\TestCase
  11. {
  12. public function testGetMethods()
  13. {
  14. /** @var $layout \Magento\Framework\View\Layout */
  15. $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  16. \Magento\Framework\View\LayoutInterface::class
  17. );
  18. $child = $layout->createBlock(
  19. \Magento\Framework\View\Element\Text::class
  20. )->setChild(
  21. 'child1',
  22. $layout->createBlock(
  23. \Magento\Framework\View\Element\Text::class,
  24. 'method1'
  25. )
  26. )->setChild(
  27. 'child2',
  28. $layout->createBlock(
  29. \Magento\Framework\View\Element\Text::class,
  30. 'method2'
  31. )
  32. );
  33. /** @var $block \Magento\Checkout\Block\Cart */
  34. $block = $layout->createBlock(\Magento\Checkout\Block\Cart::class)->setChild('child', $child);
  35. $methods = $block->getMethods('child');
  36. $this->assertEquals(['method1', 'method2'], $methods);
  37. }
  38. public function testGetMethodsEmptyChild()
  39. {
  40. /** @var $layout \Magento\Framework\View\Layout */
  41. $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  42. \Magento\Framework\View\LayoutInterface::class
  43. );
  44. $childEmpty = $layout->createBlock(\Magento\Framework\View\Element\Text::class);
  45. /** @var $block \Magento\Checkout\Block\Cart */
  46. $block = $layout->createBlock(\Magento\Checkout\Block\Cart::class)->setChild('child', $childEmpty);
  47. $methods = $block->getMethods('child');
  48. $this->assertEquals([], $methods);
  49. }
  50. public function testGetMethodsNoChild()
  51. {
  52. /** @var $layout \Magento\Framework\View\Layout */
  53. $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  54. \Magento\Framework\View\LayoutInterface::class
  55. );
  56. /** @var $block \Magento\Checkout\Block\Cart */
  57. $block = $layout->createBlock(\Magento\Checkout\Block\Cart::class);
  58. $methods = $block->getMethods('child');
  59. $this->assertEquals([], $methods);
  60. }
  61. public function testGetPagerHtml()
  62. {
  63. /** @var $layout \Magento\Framework\View\Layout */
  64. $layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
  65. \Magento\Framework\View\LayoutInterface::class
  66. );
  67. /** @var $block \Magento\Checkout\Block\Cart */
  68. $block = $layout->createBlock(\Magento\Checkout\Block\Cart::class);
  69. $pager = $block->getPagerHtml();
  70. $this->assertEquals('', $pager);
  71. }
  72. }