Skip to content

Commit a7806f2

Browse files
committed
Merge remote-tracking branch 'ogresCE/MAGETWO-39647-autoload-error-after-running-setupdicompile' into PR_Branch
2 parents 4fd68c3 + c5b6438 commit a7806f2

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

dev/tests/integration/testsuite/Magento/Framework/Composer/ComposerInformationTest.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class ComposerInformationTest extends \PHPUnit_Framework_TestCase
2626
*/
2727
private $ioMock;
2828

29+
/**
30+
* @var BufferIoFactory|\PHPUnit_Framework_MockObject_MockObject
31+
*/
32+
private $bufferIoFactoryMock;
33+
2934
public function setUp()
3035
{
3136
$this->directoryReadMock = $this->getMock('Magento\Framework\Filesystem\Directory\Read', [], [], '', false);
@@ -35,6 +40,8 @@ public function setUp()
3540
->method('getDirectoryRead')
3641
->will($this->returnValue($this->directoryReadMock));
3742
$this->ioMock = $this->getMock('Composer\IO\BufferIO', [], [], '', false);
43+
$this->bufferIoFactoryMock = $this->getMock('Magento\Framework\Composer\BufferIoFactory', [], [], '', false);
44+
$this->bufferIoFactoryMock->expects($this->any())->method('create')->willReturn($this->ioMock);
3845
}
3946

4047
/**
@@ -63,7 +70,7 @@ private function setupDirectoryMock($composerDir)
6370
public function testGetRequiredPhpVersion($composerDir)
6471
{
6572
$this->setupDirectoryMock($composerDir);
66-
$composerInfo = new ComposerInformation($this->filesystemMock, $this->ioMock);
73+
$composerInfo = new ComposerInformation($this->filesystemMock, $this->bufferIoFactoryMock);
6774
$this->assertEquals("~5.5.0|~5.6.0", $composerInfo->getRequiredPhpVersion());
6875
}
6976

@@ -75,7 +82,7 @@ public function testGetRequiredPhpVersion($composerDir)
7582
public function testGetRequiredExtensions($composerDir)
7683
{
7784
$this->setupDirectoryMock($composerDir);
78-
$composerInfo = new ComposerInformation($this->filesystemMock, $this->ioMock);
85+
$composerInfo = new ComposerInformation($this->filesystemMock, $this->bufferIoFactoryMock);
7986
$expectedExtensions = ['ctype', 'gd', 'spl', 'dom', 'simplexml', 'mcrypt', 'hash', 'curl', 'iconv', 'intl'];
8087

8188
$actualRequiredExtensions = $composerInfo->getRequiredExtensions();
@@ -92,7 +99,7 @@ public function testGetRequiredExtensions($composerDir)
9299
public function testGetRootRequiredPackagesAndTypes($composerDir)
93100
{
94101
$this->setupDirectoryMock($composerDir);
95-
$composerInfo = new ComposerInformation($this->filesystemMock, $this->ioMock);
102+
$composerInfo = new ComposerInformation($this->filesystemMock, $this->bufferIoFactoryMock);
96103

97104
$requiredPackagesAndTypes = $composerInfo->getRootRequiredPackageTypesByName();
98105

@@ -121,6 +128,6 @@ public function getRequiredPhpVersionDataProvider()
121128
public function testNoLock()
122129
{
123130
$this->setupDirectoryMock('notARealDirectory');
124-
new ComposerInformation($this->filesystemMock, $this->ioMock);
131+
new ComposerInformation($this->filesystemMock, $this->bufferIoFactoryMock);
125132
}
126133
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Composer;
8+
9+
use Composer\IO\BufferIO;
10+
11+
/**
12+
* Class creates BufferIO instance
13+
*/
14+
class BufferIoFactory
15+
{
16+
/**
17+
* Creates BufferIO instance
18+
*
19+
* @return BufferIO
20+
*/
21+
public function create()
22+
{
23+
return new BufferIO();
24+
}
25+
}

lib/internal/Magento/Framework/Composer/ComposerInformation.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
namespace Magento\Framework\Composer;
88

99
use Composer\Factory as ComposerFactory;
10-
use Composer\IO\BufferIO;
1110
use Composer\Package\Link;
1211
use Composer\Package\PackageInterface;
1312
use Magento\Framework\App\Filesystem\DirectoryList;
@@ -32,12 +31,12 @@ class ComposerInformation
3231
* Constructor
3332
*
3433
* @param Filesystem $filesystem
35-
* @param BufferIO $io
34+
* @param BufferIoFactory $bufferIoFactory
3635
* @throws \Exception
3736
*/
3837
public function __construct(
3938
Filesystem $filesystem,
40-
BufferIO $io
39+
BufferIoFactory $bufferIoFactory
4140
) {
4241
// composer.json is in same directory as vendor
4342
$vendorPath = $filesystem->getDirectoryRead(DirectoryList::CONFIG)->getAbsolutePath('vendor_path.php');
@@ -53,7 +52,7 @@ public function __construct(
5352
putenv('COMPOSER_HOME=' . $filesystem->getDirectoryRead(DirectoryList::COMPOSER_HOME)->getAbsolutePath());
5453

5554
// Create Composer
56-
$this->composer = ComposerFactory::create($io, $composerJson);
55+
$this->composer = ComposerFactory::create($bufferIoFactory->create(), $composerJson);
5756
$this->locker = $this->composer->getLocker();
5857
}
5958

0 commit comments

Comments
 (0)