Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TransportInterfacePluginTest.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class TransportInterfacePluginTest extends \PHPUnit\Framework\TestCase
17 {
21  private $transportMock;
22 
26  private $scopeConfigMock;
27 
31  private $proceedMock;
32 
36  private $isProceedMockCalled = false;
37 
41  private $model;
42 
43  protected function setUp()
44  {
45  $this->transportMock = $this->createMock(TransportInterface::class);
46  $this->scopeConfigMock = $this->getMockForAbstractClass(ScopeConfigInterface::class);
47  $this->proceedMock = function () {
48  $this->isProceedMockCalled = true;
49  };
50 
51  $this->model = new TransportInterfacePlugin($this->scopeConfigMock);
52  }
53 
59  public function testAroundSendMessage(bool $isDisabled, bool $shouldProceedRun)
60  {
61  $this->isProceedMockCalled = false;
62 
63  $this->scopeConfigMock->expects($this->once())
64  ->method('isSetFlag')
65  ->with('system/smtp/disable', ScopeInterface::SCOPE_STORE)
66  ->willReturn($isDisabled);
67  $this->model->aroundSendMessage($this->transportMock, $this->proceedMock);
68  $this->assertEquals($shouldProceedRun, $this->isProceedMockCalled);
69  }
70 
75  public function sendMessageDataProvider()
76  {
77  return [
78  [false, true],
79  [true, false],
80  ];
81  }
82 }