Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
NotifierPoolTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class NotifierPoolTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $notifierPool;
15 
18 
20  protected $notifierList;
21 
25  protected $notifiers;
26 
27  protected function setUp()
28  {
29  $this->objectManagerHelper = new ObjectManagerHelper($this);
30  $notifier1 = $this->createMock(\Magento\Framework\Notification\NotifierPool::class);
31  $notifier2 = $this->createMock(\Magento\Framework\Notification\NotifierPool::class);
32  $this->notifiers = [$notifier1, $notifier2];
33  $this->notifierList = $this->createMock(\Magento\Framework\Notification\NotifierList::class);
34  $this->notifierList->expects($this->any())->method('asArray')->will($this->returnValue($this->notifiers));
35  $this->notifierPool = $this->objectManagerHelper->getObject(
36  \Magento\Framework\Notification\NotifierPool::class,
37  [
38  'notifierList' => $this->notifierList
39  ]
40  );
41  }
42 
43  public function testAdd()
44  {
46  $title = 'title';
47  $description = 'desc';
48  foreach ($this->notifiers as $notifier) {
49  $notifier->expects($this->once())->method('add')->with($severity, $title, $description);
50  }
51  $this->notifierPool->add($severity, $title, $description);
52  }
53 
54  public function testAddCritical()
55  {
56  $title = 'title';
57  $description = 'desc';
58  foreach ($this->notifiers as $notifier) {
59  $notifier->expects($this->once())->method('addCritical')->with($title, $description);
60  }
61  $this->notifierPool->addCritical($title, $description);
62  }
63 
64  public function testAddMajor()
65  {
66  $title = 'title';
67  $description = 'desc';
68  foreach ($this->notifiers as $notifier) {
69  $notifier->expects($this->once())->method('addMajor')->with($title, $description);
70  }
71  $this->notifierPool->addMajor($title, $description);
72  }
73 
74  public function testAddMinor()
75  {
76  $title = 'title';
77  $description = 'desc';
78  foreach ($this->notifiers as $notifier) {
79  $notifier->expects($this->once())->method('addMinor')->with($title, $description);
80  }
81  $this->notifierPool->addMinor($title, $description);
82  }
83 
84  public function testAddNotice()
85  {
86  $title = 'title';
87  $description = 'desc';
88  foreach ($this->notifiers as $notifier) {
89  $notifier->expects($this->once())->method('addNotice')->with($title, $description);
90  }
91  $this->notifierPool->addNotice($title, $description);
92  }
93 }
$title
Definition: default.phtml:14