Skip to content

Commit 3d6690a

Browse files
committed
Add test for #24019
1 parent 025d0de commit 3d6690a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchHistoryTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,28 @@ public function testFixAppliedPatch()
8383
$adapterMock->expects($this->never())->method('insert');
8484
$this->patchHistory->fixPatch(get_class($patch1));
8585
}
86+
87+
/**
88+
* @expectedException \LogicException
89+
* @expectedExceptionMessageRegExp "Patch [a-zA-Z0-9\_]+ cannot be applied twice"
90+
*/
91+
public function testFixPatchTwice()
92+
{
93+
/** @var PatchInterface|\PHPUnit_Framework_MockObject_MockObject $patch1 */
94+
$patch = $this->createMock(PatchInterface::class);
95+
/** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $adapterMock */
96+
$adapterMock = $this->createMock(AdapterInterface::class);
97+
$this->resourceConnectionMock->expects($this->any())->method('getConnection')->willReturn($adapterMock);
98+
$this->resourceConnectionMock->expects($this->any())
99+
->method('getTableName')
100+
->willReturn(PatchHistory::TABLE_NAME);
101+
$selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
102+
$selectMock->expects($this->once())->method('from');
103+
$adapterMock->expects($this->any())->method('select')->willReturn($selectMock);
104+
$adapterMock->expects($this->once())->method('fetchCol')->willReturn([]);
105+
$adapterMock->expects($this->once())->method('insert');
106+
107+
$this->patchHistory->fixPatch(get_class($patch));
108+
$this->patchHistory->fixPatch(get_class($patch));
109+
}
86110
}

0 commit comments

Comments
 (0)