Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregateInvokerTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\App\Utility\AggregateInvoker;
9 
10 class AggregateInvokerTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $_invoker;
16 
20  protected $_testCase;
21 
22  protected function setUp()
23  {
24  $this->_testCase = $this->createPartialMock(
25  \PHPUnit\Framework\Test::class,
26  ['run', 'count', 'fail', 'markTestIncomplete', 'markTestSkipped']
27  );
28  $this->_invoker = new AggregateInvoker($this->_testCase, []);
29  }
30 
39  public function testMainFlow($expectedMessage, $expectedMethod, $exceptionClass)
40  {
41  $this->_testCase->expects(
42  $this->any()
43  )->method(
44  $expectedMethod
45  )->with(
46  $this->stringStartsWith($expectedMessage)
47  );
48  $this->_invoker->__invoke(
49  function () use ($exceptionClass) {
50  throw new $exceptionClass('Some meaningful message.');
51  },
52  [[0]]
53  );
54  }
55 
59  public function callbackDataProvider()
60  {
61  return [
62  [
63  'Passed: 0, Failed: 1, Incomplete: 0, Skipped: 0.',
64  'fail',
65  \PHPUnit\Framework\AssertionFailedError::class,
66  ],
67  ['Passed: 0, Failed: 1, Incomplete: 0, Skipped: 0.', 'fail', \PHPUnit\Framework\OutputError::class],
68  [
69  'Passed: 0, Failed: 1, Incomplete: 0, Skipped: 0.',
70  'fail',
71  \PHPUnit\Framework\ExpectationFailedException::class
72  ],
73  [
74  'Passed: 0, Failed: 0, Incomplete: 1, Skipped: 0.',
75  'markTestIncomplete',
76  \PHPUnit\Framework\IncompleteTestError::class
77  ],
78  [
79  'Passed: 0, Failed: 0, Incomplete: 0, Skipped: 1.',
80  'markTestSkipped',
81  \PHPUnit\Framework\SkippedTestError::class
82  ]
83  ];
84  }
85 }
testMainFlow($expectedMessage, $expectedMethod, $exceptionClass)