ContainerTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Braintree\Block\Form;
  7. use Magento\Braintree\Model\Ui\PayPal\ConfigProvider as PayPalConfigProvider;
  8. use Magento\Framework\App\Area;
  9. use Magento\Framework\ObjectManagerInterface;
  10. use Magento\Payment\Block\Form\Container;
  11. use Magento\Payment\Model\MethodInterface;
  12. use Magento\Quote\Api\CartRepositoryInterface;
  13. use Magento\TestFramework\Helper\Bootstrap;
  14. /**
  15. * Class ContainerTest
  16. */
  17. class ContainerTest extends \PHPUnit\Framework\TestCase
  18. {
  19. /**
  20. * @var ObjectManagerInterface
  21. */
  22. private $objectManager;
  23. /**
  24. * @var Bootstrap
  25. */
  26. private $bootstrap;
  27. /**
  28. * @var Container
  29. */
  30. private $container;
  31. protected function setUp()
  32. {
  33. $this->bootstrap = Bootstrap::getInstance();
  34. $this->bootstrap->loadArea(Area::AREA_ADMINHTML);
  35. $this->objectManager = Bootstrap::getObjectManager();
  36. $this->container = $this->objectManager->create(Container::class);
  37. }
  38. /**
  39. * @covers \Magento\Payment\Block\Form\Container::getMethods
  40. * @magentoDataFixture Magento/Braintree/_files/paypal_quote.php
  41. */
  42. public function testGetMethods()
  43. {
  44. $customerId = 1;
  45. /** @var CartRepositoryInterface $quoteRepository */
  46. $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
  47. $quote = $quoteRepository->getForCustomer($customerId);
  48. $this->container->setData('quote', $quote);
  49. $actual = $this->container->getMethods();
  50. /** @var MethodInterface $paymentMethod */
  51. foreach ($actual as $paymentMethod) {
  52. static::assertNotContains($paymentMethod->getCode(), [
  53. PayPalConfigProvider::PAYPAL_VAULT_CODE, PayPalConfigProvider::PAYPAL_CODE
  54. ]);
  55. }
  56. }
  57. }