Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
MagentoTest.php
Go to the documentation of this file.
1 <?php
11 
12 class MagentoTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_object;
18 
22  protected $_eventManager;
23 
24  protected function setUp()
25  {
26  $this->_eventManager = $this->getMockBuilder(\Magento\TestFramework\EventManager::class)
27  ->setMethods(['fireEvent'])
28  ->setConstructorArgs([[]])
29  ->getMock();
30  $this->_object = new \Magento\TestFramework\Event\Magento($this->_eventManager);
31  }
32 
33  protected function tearDown()
34  {
36  }
37 
39  {
41  $this->_object = new \Magento\TestFramework\Event\Magento();
42  $this->testInitStoreAfter();
43  }
44 
50  public function testConstructorException($eventManager)
51  {
52  new \Magento\TestFramework\Event\Magento($eventManager);
53  }
54 
56  {
57  return ['no event manager' => [null], 'not an event manager' => [new \stdClass()]];
58  }
59 
60  public function testInitStoreAfter()
61  {
62  $this->_eventManager->expects($this->once())->method('fireEvent')->with('initStoreAfter');
63  $this->_object->execute($this->createMock(\Magento\Framework\Event\Observer::class));
64  }
65 }
static setDefaultEventManager(\Magento\TestFramework\EventManager $eventManager=null)
Definition: Magento.php:33
testConstructorException($eventManager)
Definition: MagentoTest.php:50