Skip to content

Commit c686b4d

Browse files
committed
MC-2338: 3rd party library/dependency upgrade for 2.3 pre Alpha
1 parent c647bfe commit c686b4d

File tree

3 files changed

+69
-15
lines changed

3 files changed

+69
-15
lines changed

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Event/TransactionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ protected function setUp()
3030
{
3131
$this->_eventManager = $this->getMockBuilder(\Magento\TestFramework\EventManager::class)
3232
->setMethods(['fireEvent'])
33-
->setConstructorArgs([[]])
33+
->disableOriginalConstructor()
3434
->getMock();
3535

3636
$this->_adapter =
@@ -69,9 +69,9 @@ protected function _imitateTransactionStartRequest($eventName)
6969
/**
7070
* Setup expectations for "transaction start" use case
7171
*
72-
* @param \PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher
72+
* @param \PHPUnit\Framework\MockObject\Matcher\Invocation $invocationMatcher
7373
*/
74-
protected function _expectTransactionStart(\PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher)
74+
protected function _expectTransactionStart(\PHPUnit\Framework\MockObject\Matcher\Invocation $invocationMatcher)
7575
{
7676
$this->_eventManager->expects($invocationMatcher)->method('fireEvent')->with('startTransaction');
7777
$this->_adapter->expects($this->once())->method('beginTransaction');
@@ -103,9 +103,9 @@ protected function _imitateTransactionRollbackRequest($eventName)
103103
/**
104104
* Setup expectations for "transaction rollback" use case
105105
*
106-
* @param \PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher
106+
* @param \PHPUnit\Framework\MockObject\Matcher\Invocation $invocationMatcher
107107
*/
108-
protected function _expectTransactionRollback(\PHPUnit_Framework_MockObject_Matcher_Invocation $invocationMatcher)
108+
protected function _expectTransactionRollback(\PHPUnit\Framework\MockObject\Matcher\Invocation $invocationMatcher)
109109
{
110110
$this->_eventManager->expects($invocationMatcher)->method('fireEvent')->with('rollbackTransaction');
111111
$this->_adapter->expects($this->once())->method('rollback');

lib/internal/Magento/Framework/TestFramework/Test/Unit/Unit/Matcher/MethodInvokedAtIndexTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class MethodInvokedAtIndexTest extends \PHPUnit\Framework\TestCase
1111
{
1212
public function testMatches()
1313
{
14-
$invocationObject = new \PHPUnit_Framework_MockObject_Invocation_Object(
14+
$invocationObject = new \PHPUnit\Framework\MockObject\Invocation\ObjectInvocation(
1515
'ClassName',
1616
'ValidMethodName',
1717
[],
1818
'void',
1919
new \StdClass()
2020
);
21-
$matcher = new \Magento\Framework\TestFramework\Unit\Matcher\MethodInvokedAtIndex(0);
21+
$matcher = new MethodInvokedAtIndex(0);
2222
$this->assertTrue($matcher->matches($invocationObject));
2323

2424
$matcher = new MethodInvokedAtIndex(1);

lib/internal/Magento/Framework/TestFramework/Unit/Matcher/MethodInvokedAtIndex.php

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Framework\TestFramework\Unit\Matcher;
88

9+
use PHPUnit\Framework\ExpectationFailedException;
10+
use PHPUnit\Framework\MockObject\Invocation as BaseInvocation;
11+
912
/**
1013
* Class MethodInvokedAtIndex
1114
* Matches invocations per 'method' at 'position'
@@ -18,30 +21,81 @@
1821
*
1922
* @package Magento\TestFramework\Matcher
2023
*/
21-
class MethodInvokedAtIndex extends \PHPUnit_Framework_MockObject_Matcher_InvokedAtIndex
24+
class MethodInvokedAtIndex implements \PHPUnit\Framework\MockObject\Matcher\Invocation
2225
{
26+
/**
27+
* @var int
28+
*/
29+
private $sequenceIndex;
30+
31+
/**
32+
* @var int
33+
*/
34+
private $currentIndex = -1;
35+
2336
/**
2437
* @var array
2538
*/
26-
protected $indexes = [];
39+
private $indexes = [];
40+
41+
/**
42+
* @param int $sequenceIndex
43+
*/
44+
public function __construct($sequenceIndex)
45+
{
46+
$this->sequenceIndex = $sequenceIndex;
47+
}
48+
49+
/**
50+
* @return string
51+
*/
52+
public function toString()
53+
{
54+
return 'invoked at sequence index ' . $this->sequenceIndex;
55+
}
2756

2857
/**
29-
* @param \PHPUnit_Framework_MockObject_Invocation $invocation
58+
* @param \PHPUnit\Framework\MockObject\Invocation $invocation
3059
* @return boolean
3160
*/
32-
public function matches(\PHPUnit_Framework_MockObject_Invocation $invocation)
61+
public function matches(BaseInvocation $invocation)
3362
{
3463
/** @noinspection PhpUndefinedFieldInspection */
35-
if (!isset($this->indexes[$invocation->methodName])) {
64+
if (!isset($this->indexes[$invocation->getMethodName()])) {
3665
/** @noinspection PhpUndefinedFieldInspection */
37-
$this->indexes[$invocation->methodName] = 0;
66+
$this->indexes[$invocation->getMethodName()] = 0;
3867
} else {
3968
/** @noinspection PhpUndefinedFieldInspection */
40-
$this->indexes[$invocation->methodName]++;
69+
$this->indexes[$invocation->getMethodName()]++;
4170
}
4271
$this->currentIndex++;
4372

4473
/** @noinspection PhpUndefinedFieldInspection */
45-
return $this->indexes[$invocation->methodName] == $this->sequenceIndex;
74+
return $this->indexes[$invocation->getMethodName()] == $this->sequenceIndex;
75+
}
76+
77+
/**
78+
* @param BaseInvocation $invocation
79+
*/
80+
public function invoked(BaseInvocation $invocation)
81+
{
82+
}
83+
84+
/**
85+
* Verifies that the current expectation is valid. If everything is OK the
86+
* code should just return, if not it must throw an exception.
87+
*
88+
* @throws ExpectationFailedException
89+
*/
90+
public function verify()
91+
{
92+
if ($this->currentIndex < $this->sequenceIndex) {
93+
throw new ExpectationFailedException(
94+
\sprintf(
95+
'The expected invocation at index %s was never reached.',
96+
$this->sequenceIndex
97+
)
98+
);
99+
}
46100
}
47101
}

0 commit comments

Comments
 (0)