ExchangeInstallerTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Amqp\Test\Unit\Topology;
  7. use Magento\Framework\Amqp\Topology\ExchangeInstaller;
  8. use Magento\Framework\Amqp\Topology\BindingInstallerInterface;
  9. use Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItemInterface;
  10. use PhpAmqpLib\Channel\AMQPChannel;
  11. use Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\BindingInterface;
  12. class ExchangeInstallerTest extends \PHPUnit\Framework\TestCase
  13. {
  14. public function testInstall()
  15. {
  16. $bindingInstaller = $this->createMock(BindingInstallerInterface::class);
  17. $model = new ExchangeInstaller($bindingInstaller);
  18. $channel = $this->createMock(AMQPChannel::class);
  19. $binding = $this->createMock(BindingInterface::class);
  20. $exchange = $this->createMock(ExchangeConfigItemInterface::class);
  21. $exchange->expects($this->exactly(2))->method('getName')->willReturn('magento');
  22. $exchange->expects($this->once())->method('getType')->willReturn('topic');
  23. $exchange->expects($this->once())->method('isDurable')->willReturn(true);
  24. $exchange->expects($this->once())->method('isAutoDelete')->willReturn(false);
  25. $exchange->expects($this->once())->method('isInternal')->willReturn(false);
  26. $exchange->expects($this->once())->method('getArguments')->willReturn(['some' => 'value']);
  27. $exchange->expects($this->once())->method('getBindings')->willReturn(['bind01' => $binding]);
  28. $channel->expects($this->once())
  29. ->method('exchange_declare')
  30. ->with('magento', 'topic', false, true, false, false, false, ['some' => ['S', 'value']], null);
  31. $bindingInstaller->expects($this->once())->method('install')->with($channel, $binding, 'magento');
  32. $model->install($channel, $exchange);
  33. }
  34. }