Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ExchangeRepositoryTest.php
Go to the documentation of this file.
1 <?php
8 
12 class ExchangeRepositoryTest extends \PHPUnit\Framework\TestCase
13 {
17  private $exchangeFactory;
18 
22  private $exchangeRepository;
23 
29  protected function setUp()
30  {
31  $this->exchangeFactory = $this
32  ->getMockBuilder(\Magento\Framework\MessageQueue\Bulk\ExchangeFactoryInterface::class)
33  ->disableOriginalConstructor()->getMock();
34 
35  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
36  $this->exchangeRepository = $objectManager->getObject(
37  \Magento\Framework\MessageQueue\Bulk\ExchangeRepository::class
38  );
39  $objectManager->setBackwardCompatibleProperty(
40  $this->exchangeRepository,
41  'exchangeFactory',
42  $this->exchangeFactory
43  );
44  }
45 
51  public function testGetByConnectionName()
52  {
53  $connectionName = 'amqp';
54  $exchange = $this
55  ->getMockBuilder(\Magento\Framework\Amqp\Bulk\Exchange::class)
56  ->disableOriginalConstructor()->getMock();
57  $this->exchangeFactory->expects($this->once())->method('create')->with($connectionName)->willReturn($exchange);
58  $this->assertEquals($exchange, $this->exchangeRepository->getByConnectionName($connectionName));
59  }
60 }
$objectManager
Definition: bootstrap.php:17