22 private $validatorMock;
27 private $readerOneMock;
32 private $readerTwoMock;
37 private $readerThreeMock;
49 $this->validatorMock = $this->createMock(ValidatorInterface::class);
50 $this->readerOneMock = $this->createMock(ReaderInterface::class);
51 $this->readerTwoMock = $this->createMock(ReaderInterface::class);
52 $this->readerThreeMock = $this->createMock(ReaderInterface::class);
53 $this->defaultConfigProviderMock =
54 $this->createMock(\
Magento\Framework\MessageQueue\DefaultValueProvider::class);
58 $this->defaultConfigProviderMock,
60 'readerOne' => $this->readerOneMock,
61 'readerThree' => $this->readerThreeMock,
62 'readerTwo' => $this->readerTwoMock,
69 $this->defaultConfigProviderMock->expects($this->any())->method(
'getConnection')->willReturn(
'amqp');
70 $this->defaultConfigProviderMock->expects($this->any())->method(
'getExchange')->willReturn(
'magento');
72 $dataOne = include
__DIR__ .
'/../../_files/queue_publisher/reader_one.php';
73 $dataTwo = include
__DIR__ .
'/../../_files/queue_publisher/reader_two.php';
74 $expectedValidationData = include
__DIR__ .
'/../../_files/queue_publisher/data_to_validate.php';
76 $this->readerOneMock->expects($this->once())->method(
'read')->with(
null)->willReturn($dataOne);
77 $this->readerTwoMock->expects($this->once())->method(
'read')->with(
null)->willReturn($dataTwo);
78 $this->readerThreeMock->expects($this->once())->method(
'read')->with(
null)->willReturn([]);
80 $this->validatorMock->expects($this->once())->method(
'validate')->with($expectedValidationData);
82 $data = $this->reader->read();
89 'connection' => [
'name' =>
'db',
'disabled' =>
false,
'exchange' =>
'magento2'],
95 'connection' => [
'name' =>
'amqp',
'exchange' =>
'exch01',
'disabled' =>
false],
101 'connection' => [
'name' =>
'amqp',
'exchange' =>
'magento',
'disabled' =>
false],
107 'connection' => [
'name' =>
'amqp',
'exchange' =>
'magento',
'disabled' =>
false],
111 $this->assertEquals($expectedData,
$data);
defined('TESTS_BP')||define('TESTS_BP' __DIR__
$defaultConfigProviderMock