Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
PhpUnitTest Class Reference
Inheritance diagram for PhpUnitTest:

Public Member Functions

 testConstructorDefaultEventManager ()
 
 testConstructorException ()
 
 testDoNotFireEvent ($method)
 
 doNotFireEventDataProvider ()
 
 testStartTestSuiteFireEvent ()
 
 testStartTestSuiteDoNotFireEvent ()
 
 testEndTestSuiteFireEvent ()
 
 testEndTestSuiteDoNotFireEvent ()
 
 testStartTestFireEvent ()
 
 testStartTestDoNotFireEvent ()
 
 testEndTestFireEvent ()
 
 testEndTestDoNotFireEvent ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $_object
 
 $_eventManager
 

Detailed Description

Definition at line 12 of file PhpUnitTest.php.

Member Function Documentation

◆ doNotFireEventDataProvider()

doNotFireEventDataProvider ( )

Definition at line 63 of file PhpUnitTest.php.

64  {
65  return [
66  'method "addError"' => ['addError'],
67  'method "addFailure"' => ['addFailure'],
68  'method "addIncompleteTest"' => ['addIncompleteTest'],
69  'method "addSkippedTest"' => ['addSkippedTest']
70  ];
71  }

◆ setUp()

setUp ( )
protected

Definition at line 24 of file PhpUnitTest.php.

25  {
26  $this->_eventManager = $this->getMockBuilder(\Magento\TestFramework\EventManager::class)
27  ->setMethods(['fireEvent'])
28  ->setConstructorArgs([[]])
29  ->getMock();
30  $this->_object = new \Magento\TestFramework\Event\PhpUnit($this->_eventManager);
31  }

◆ tearDown()

tearDown ( )
protected

Definition at line 33 of file PhpUnitTest.php.

34  {
36  }
static setDefaultEventManager(\Magento\TestFramework\EventManager $eventManager=null)
Definition: PhpUnit.php:31

◆ testConstructorDefaultEventManager()

testConstructorDefaultEventManager ( )

Definition at line 38 of file PhpUnitTest.php.

39  {
41  $this->_object = new \Magento\TestFramework\Event\PhpUnit();
43  }
static setDefaultEventManager(\Magento\TestFramework\EventManager $eventManager=null)
Definition: PhpUnit.php:31

◆ testConstructorException()

testConstructorException ( )

@expectedException \Magento\Framework\Exception\LocalizedException

Definition at line 48 of file PhpUnitTest.php.

49  {
50  new \Magento\TestFramework\Event\Magento();
51  }

◆ testDoNotFireEvent()

testDoNotFireEvent (   $method)
Parameters
string$method@dataProvider doNotFireEventDataProvider

Definition at line 57 of file PhpUnitTest.php.

58  {
59  $this->_eventManager->expects($this->never())->method('fireEvent');
60  $this->_object->{$method}($this, new \PHPUnit\Framework\AssertionFailedError(), 0);
61  }
$method
Definition: info.phtml:13

◆ testEndTestDoNotFireEvent()

testEndTestDoNotFireEvent ( )

Definition at line 116 of file PhpUnitTest.php.

117  {
118  $this->_eventManager->expects($this->never())->method('fireEvent');
119  // $this->_object->endTest(new \PHPUnit\Framework\Warning(), 0);
120  $this->_object->endTest($this->createMock(\PHPUnit\Framework\Test::class), 0);
121  }

◆ testEndTestFireEvent()

testEndTestFireEvent ( )

Definition at line 110 of file PhpUnitTest.php.

111  {
112  $this->_eventManager->expects($this->once())->method('fireEvent')->with('endTest');
113  $this->_object->endTest($this, 0);
114  }

◆ testEndTestSuiteDoNotFireEvent()

testEndTestSuiteDoNotFireEvent ( )

Definition at line 91 of file PhpUnitTest.php.

92  {
93  $this->_eventManager->expects($this->never())->method('fireEvent');
94  $this->_object->endTestSuite(new \PHPUnit\Framework\DataProviderTestSuite());
95  }

◆ testEndTestSuiteFireEvent()

testEndTestSuiteFireEvent ( )

Definition at line 85 of file PhpUnitTest.php.

86  {
87  $this->_eventManager->expects($this->once())->method('fireEvent')->with('endTestSuite');
88  $this->_object->endTestSuite(new \PHPUnit\Framework\TestSuite());
89  }

◆ testStartTestDoNotFireEvent()

testStartTestDoNotFireEvent ( )

Definition at line 103 of file PhpUnitTest.php.

104  {
105  $this->_eventManager->expects($this->never())->method('fireEvent');
106  // $this->_object->startTest(new \PHPUnit\Framework\Warning());
107  $this->_object->startTest($this->createMock(\PHPUnit\Framework\Test::class));
108  }

◆ testStartTestFireEvent()

testStartTestFireEvent ( )

Definition at line 97 of file PhpUnitTest.php.

98  {
99  $this->_eventManager->expects($this->once())->method('fireEvent')->with('startTest');
100  $this->_object->startTest($this);
101  }

◆ testStartTestSuiteDoNotFireEvent()

testStartTestSuiteDoNotFireEvent ( )

Definition at line 79 of file PhpUnitTest.php.

80  {
81  $this->_eventManager->expects($this->never())->method('fireEvent');
82  $this->_object->startTestSuite(new \PHPUnit\Framework\DataProviderTestSuite());
83  }

◆ testStartTestSuiteFireEvent()

testStartTestSuiteFireEvent ( )

Definition at line 73 of file PhpUnitTest.php.

74  {
75  $this->_eventManager->expects($this->once())->method('fireEvent')->with('startTestSuite');
76  $this->_object->startTestSuite(new \PHPUnit\Framework\TestSuite());
77  }

Field Documentation

◆ $_eventManager

$_eventManager
protected

Definition at line 22 of file PhpUnitTest.php.

◆ $_object

$_object
protected

Definition at line 17 of file PhpUnitTest.php.


The documentation for this class was generated from the following file: