Skip to content

Commit 551b1e2

Browse files
committed
AC-5972: Fix for Unit-test case which were failing after composer code changes
1 parent 620482b commit 551b1e2

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

lib/internal/Magento/Framework/Composer/Test/Unit/ComposerInformationTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Composer\Package\CompletePackageInterface;
1212
use Composer\Package\Locker;
1313
use Composer\Package\RootPackageInterface;
14-
use Composer\Repository\RepositoryInterface;
14+
use Composer\Repository\LockArrayRepository;
1515
use Magento\Framework\Composer\ComposerInformation;
1616
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1717
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
@@ -36,7 +36,7 @@ class ComposerInformationTest extends TestCase
3636
private $lockerMock;
3737

3838
/**
39-
* @var RepositoryInterface|InvocationMocker
39+
* @var LockArrayRepository|InvocationMocker
4040
*/
4141
private $lockerRepositoryMock;
4242

@@ -53,7 +53,10 @@ protected function setUp(): void
5353
$this->lockerMock = $this->getMockBuilder(Locker::class)
5454
->disableOriginalConstructor()
5555
->getMock();
56-
$this->lockerRepositoryMock = $this->getMockForAbstractClass(RepositoryInterface::class);
56+
$this->lockerRepositoryMock = $this->getMockBuilder(LockArrayRepository::class)
57+
->setMethods(['getLockedRepository','getPackages'])
58+
->disableOriginalConstructor()
59+
->getMock();
5760
$this->packageMock = $this->getMockForAbstractClass(CompletePackageInterface::class);
5861
$this->lockerMock->method('getLockedRepository')->willReturn($this->lockerRepositoryMock);
5962
$this->packageMock->method('getType')->willReturn('metapackage');

lib/internal/Magento/Framework/Composer/Test/Unit/DependencyCheckerTest.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ class DependencyCheckerTest extends TestCase
2020
*/
2121
public function testCheckDependencies(): void
2222
{
23-
$composerApp =
24-
$this->createPartialMock(Application::class, ['setAutoExit', 'resetComposer', 'run']);
23+
$composerApp = $this->getMockBuilder(Application::class)
24+
->setMethods(['setAutoExit', 'resetComposer', 'run','__destruct'])
25+
->disableOriginalConstructor()
26+
->getMock();
2527
$directoryList = $this->createMock(DirectoryList::class);
2628
$directoryList->expects($this->exactly(2))->method('getRoot');
2729
$composerApp->expects($this->once())->method('setAutoExit')->with(false);
30+
$composerApp->expects($this->any())->method('__destruct');
2831

2932
$composerApp
3033
->method('run')
@@ -35,6 +38,7 @@ function ($input, $buffer) {
3538
'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL .
3639
'magento/package-c requires magento/package-a (1.0)' . PHP_EOL;
3740
$buffer->writeln($output);
41+
return 1;
3842
}
3943
),
4044
$this->returnCallback(
@@ -43,6 +47,7 @@ function ($input, $buffer) {
4347
'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL .
4448
'magento/package-d requires magento/package-b (1.0)' . PHP_EOL;
4549
$buffer->writeln($output);
50+
return 1;
4651
}
4752
)
4853
);
@@ -64,11 +69,14 @@ function ($input, $buffer) {
6469
*/
6570
public function testCheckDependenciesExcludeSelf(): void
6671
{
67-
$composerApp =
68-
$this->createPartialMock(Application::class, ['setAutoExit', 'resetComposer', 'run']);
72+
$composerApp = $this->getMockBuilder(Application::class)
73+
->setMethods(['setAutoExit', 'resetComposer', 'run','__destruct'])
74+
->disableOriginalConstructor()
75+
->getMock();
6976
$directoryList = $this->createMock(DirectoryList::class);
7077
$directoryList->expects($this->exactly(3))->method('getRoot');
7178
$composerApp->expects($this->once())->method('setAutoExit')->with(false);
79+
$composerApp->expects($this->any())->method('__destruct');
7280

7381
$composerApp
7482
->method('run')
@@ -79,6 +87,7 @@ function ($input, $buffer) {
7987
'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL .
8088
'magento/package-c requires magento/package-a (1.0)' . PHP_EOL;
8189
$buffer->writeln($output);
90+
return 1;
8291
}
8392
),
8493
$this->returnCallback(
@@ -87,13 +96,15 @@ function ($input, $buffer) {
8796
'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL .
8897
'magento/package-d requires magento/package-b (1.0)' . PHP_EOL;
8998
$buffer->writeln($output);
99+
return 1;
90100
}
91101
),
92102
$this->returnCallback(
93103
function ($input, $buffer) {
94104
$output = 'magento/package-d requires magento/package-c (1.0)' . PHP_EOL .
95105
'magento/project-community-edition requires magento/package-a (1.0)' . PHP_EOL;
96106
$buffer->writeln($output);
107+
return 1;
97108
}
98109
)
99110
);

0 commit comments

Comments
 (0)