17 private $connectionTypeResolver;
22 private $amqpExchangeFactory;
27 private $exchangeFactory;
36 $this->connectionTypeResolver = $this
37 ->getMockBuilder(\
Magento\Framework\MessageQueue\ConnectionTypeResolver::class)
38 ->disableOriginalConstructor()->getMock();
40 $this->amqpExchangeFactory = $this
41 ->getMockBuilder(\
Magento\Framework\Amqp\ExchangeFactory::class)
42 ->disableOriginalConstructor()
45 $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
47 \
Magento\Framework\MessageQueue\Bulk\ExchangeFactory::class,
49 'connectionTypeResolver' => $this->connectionTypeResolver,
50 'exchangeFactories' => [
'amqp' => $this->amqpExchangeFactory],
62 $connectionName =
'amqp';
63 $data = [
'key1' =>
'value1'];
64 $this->connectionTypeResolver->expects($this->once())
65 ->method(
'getConnectionType')->with($connectionName)->willReturn($connectionName);
67 ->getMockBuilder(\
Magento\Framework\Amqp\Bulk\Exchange::class)
68 ->disableOriginalConstructor()->getMock();
69 $this->amqpExchangeFactory->expects($this->once())
70 ->method(
'create')->with($connectionName,
$data)->willReturn($exchange);
71 $this->assertEquals($exchange, $this->exchangeFactory->create($connectionName,
$data));
83 $connectionName =
'db';
84 $data = [
'key1' =>
'value1'];
85 $this->connectionTypeResolver->expects($this->once())
86 ->method(
'getConnectionType')->with($connectionName)->willReturn($connectionName);
87 $this->amqpExchangeFactory->expects($this->never())->method(
'create');
88 $this->exchangeFactory->create($connectionName,
$data);
100 $connectionName =
'amqp';
101 $data = [
'key1' =>
'value1'];
102 $this->connectionTypeResolver->expects($this->once())
103 ->method(
'getConnectionType')->with($connectionName)->willReturn($connectionName);
105 ->getMockBuilder(\
Magento\Framework\Amqp\Exchange::class)
106 ->disableOriginalConstructor()->getMock();
107 $this->amqpExchangeFactory->expects($this->once())
108 ->method(
'create')->with($connectionName,
$data)->willReturn($exchange);
109 $this->exchangeFactory->create($connectionName,
$data);
testCreateWithUndefinedConnectionType()
testCreateWithWrongExchangeType()