Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NotifierListTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class NotifierListTest extends \PHPUnit\Framework\TestCase
12 {
15 
17  protected $objectManager;
18 
19  protected function setUp()
20  {
21  $this->objectManager = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
22  $this->objectManagerHelper = new ObjectManagerHelper($this);
23  }
24 
25  public function testAsArraySuccess()
26  {
27  $notifier1 = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class);
28  $notifier2 = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class);
29  $notifierList = $this->objectManagerHelper->getObject(
30  \Magento\Framework\Notification\NotifierList::class,
31  [
32  'objectManager' => $this->objectManager,
33  'notifiers' => [$notifier1, $notifier2]
34  ]
35  );
36  $this->expectException('InvalidArgumentException');
37  $result = $notifierList->asArray();
38  foreach ($result as $notifier) {
39  $this->assertInstanceOf(\Magento\Framework\Notification\NotifierInterface::class, $notifier);
40  }
41  }
42 
43  public function testAsArrayException()
44  {
45  $notifierCorrect = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierPool::class);
46  $notifierIncorrect = $this->objectManagerHelper->getObject(\Magento\Framework\Notification\NotifierList::class);
47  $notifierList = $this->objectManagerHelper->getObject(
48  \Magento\Framework\Notification\NotifierList::class,
49  [
50  'objectManager' => $this->objectManager,
51  'notifiers' => [$notifierCorrect, $notifierIncorrect]
52  ]
53  );
54  $this->expectException('InvalidArgumentException');
55  $notifierList->asArray();
56  }
57 }