BindingInstallerTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\BindingInstaller;
  8. use Magento\Framework\Amqp\Topology\BindingInstallerInterface;
  9. use PhpAmqpLib\Channel\AMQPChannel;
  10. use Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\BindingInterface;
  11. class BindingInstallerTest extends \PHPUnit\Framework\TestCase
  12. {
  13. public function testInstall()
  14. {
  15. $installerOne = $this->createMock(BindingInstallerInterface::class);
  16. $installerTwo = $this->createMock(BindingInstallerInterface::class);
  17. $model = new BindingInstaller(
  18. [
  19. 'queue' => $installerOne,
  20. 'exchange' => $installerTwo,
  21. ]
  22. );
  23. $channel = $this->createMock(AMQPChannel::class);
  24. $binding = $this->createMock(BindingInterface::class);
  25. $binding->expects($this->once())->method('getDestinationType')->willReturn('queue');
  26. $installerOne->expects($this->once())->method('install')->with($channel, $binding, 'magento');
  27. $installerTwo->expects($this->never())->method('install');
  28. $model->install($channel, $binding, 'magento');
  29. }
  30. /**
  31. * @expectedException \InvalidArgumentException
  32. * @expectedExceptionMessage Installer type [test] is not configured
  33. */
  34. public function testInstallInvalidType()
  35. {
  36. $installerOne = $this->createMock(BindingInstallerInterface::class);
  37. $installerTwo = $this->createMock(BindingInstallerInterface::class);
  38. $model = new BindingInstaller(
  39. [
  40. 'queue' => $installerOne,
  41. 'exchange' => $installerTwo,
  42. ]
  43. );
  44. $channel = $this->createMock(AMQPChannel::class);
  45. $binding = $this->createMock(BindingInterface::class);
  46. $binding->expects($this->once())->method('getDestinationType')->willReturn('test');
  47. $installerOne->expects($this->never())->method('install');
  48. $installerTwo->expects($this->never())->method('install');
  49. $model->install($channel, $binding, 'magento');
  50. }
  51. }