Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DocBlockTest.php
Go to the documentation of this file.
1 <?php
11 
12 class DocBlockTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $_object;
18 
22  protected $_application;
23 
24  protected function setUp()
25  {
26  $this->_object = new \Magento\TestFramework\Bootstrap\DocBlock(__DIR__);
27  $this->_application = $this->createMock(\Magento\TestFramework\Application::class);
28  }
29 
30  protected function tearDown()
31  {
32  $this->_object = null;
33  $this->_application = null;
34  }
35 
42  protected function _expectNoListenerCreation($listenerClass, $expectedExceptionMsg)
43  {
44  try {
45  new $listenerClass();
46  $this->fail("Inability to instantiate the event listener '{$listenerClass}' is expected.");
47  } catch (\Magento\Framework\Exception\LocalizedException $e) {
48  $this->assertEquals($expectedExceptionMsg, $e->getMessage());
49  }
50  }
51 
52  public function testRegisterAnnotations()
53  {
55  \Magento\TestFramework\Event\PhpUnit::class,
56  'Instance of the event manager is required.'
57  );
59  \Magento\TestFramework\Event\Magento::class,
60  'Instance of the "Magento\TestFramework\EventManager" is expected.'
61  );
62  $this->_object->registerAnnotations($this->_application);
63  new \Magento\TestFramework\Event\PhpUnit();
64  new \Magento\TestFramework\Event\Magento();
65  }
66 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
_expectNoListenerCreation($listenerClass, $expectedExceptionMsg)