Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TopologyInstallerTest.php
Go to the documentation of this file.
1 <?php
7 
11 use PhpAmqpLib\Exception\AMQPLogicException;
12 use Psr\Log\LoggerInterface;
13 
17 class TopologyInstallerTest extends \PHPUnit\Framework\TestCase
18 {
22  private $topologyInstaller;
23 
27  private $objectManager;
28 
32  private $topologyConfigMock;
33 
37  private $loggerMock;
38 
42  protected function setUp()
43  {
44  $this->objectManager = new ObjectManager($this);
45  $this->topologyConfigMock = $this->createMock(ConfigInterface::class);
46  $this->loggerMock = $this->createMock(LoggerInterface::class);
47  $this->topologyInstaller = $this->objectManager->getObject(
48  TopologyInstaller::class,
49  ['topologyConfig' => $this->topologyConfigMock, 'logger' => $this->loggerMock]
50  );
51  parent::setUp();
52  }
53 
57  public function testInstallException()
58  {
59  $exceptionMessage = "Exception message";
60 
61  $this->topologyConfigMock
62  ->expects($this->once())
63  ->method('getQueues')
64  ->willThrowException(new AMQPLogicException($exceptionMessage));
65 
66  $this->loggerMock
67  ->expects($this->once())
68  ->method('error')
69  ->with($this->stringContains("AMQP topology installation failed: {$exceptionMessage}"));
70 
71  $this->topologyInstaller->install();
72  }
73 }