Skip to content

Commit fb45f19

Browse files
author
Yu Tang
committed
Merge remote-tracking branch 'mainline/develop' into develop
2 parents ec84dd9 + e2e4d7e commit fb45f19

File tree

67 files changed

+648
-455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+648
-455
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
sudo: required
2+
dist: trusty
3+
14
language: php
25
php:
36
- 5.5
@@ -44,12 +47,10 @@ before_script:
4447
# Install MySQL 5.6, create DB for integration tests
4548
- >
4649
sh -c "if [ '$TEST_SUITE' = 'integration_part_1' ] || [ '$TEST_SUITE' = 'integration_part_2' ] || [ '$TEST_SUITE' = 'integration_integrity' ]; then
47-
sudo apt-get remove --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
48-
sudo apt-get autoremove;
49-
sudo apt-get autoclean;
50-
sudo apt-add-repository ppa:ondrej/mysql-5.6 -y;
51-
sudo apt-get update;
52-
sudo apt-get install mysql-server-5.6 mysql-client-5.6;
50+
sudo apt-get remove -y -qq --purge mysql-common mysql-server-5.5 mysql-server-core-5.5 mysql-client-5.5 mysql-client-core-5.5;
51+
sudo apt-get -y -qq autoremove;
52+
sudo apt-get -y -qq autoclean;
53+
sudo apt-get install -y -qq mysql-server-5.6 mysql-client-5.6;
5354
mysql -uroot -e 'SET @@global.sql_mode = NO_ENGINE_SUBSTITUTION; CREATE DATABASE magento_integration_tests;';
5455
mv dev/tests/integration/etc/install-config-mysql.travis.php.dist dev/tests/integration/etc/install-config-mysql.php;
5556
fi"
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogSearch\Model\Indexer;
7+
8+
use Magento\Framework\App\Config\ScopeConfigInterface;
9+
use Magento\Framework\Indexer\IndexStructureInterface;
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Store\Model\ScopeInterface;
12+
13+
class IndexStructureFactory
14+
{
15+
/**
16+
* Object Manager instance
17+
*
18+
* @var ObjectManagerInterface
19+
*/
20+
protected $objectManager = null;
21+
22+
/**
23+
* Instance name to create
24+
*
25+
* @var string
26+
*/
27+
protected $structures = null;
28+
29+
/**
30+
* @var ScopeConfigInterface
31+
*/
32+
private $scopeConfig;
33+
34+
/**
35+
* Configuration path by which current indexer handler stored
36+
*
37+
* @var string
38+
*/
39+
private $configPath;
40+
41+
/**
42+
* Factory constructor
43+
*
44+
* @param ObjectManagerInterface $objectManager
45+
* @param ScopeConfigInterface $scopeConfig
46+
* @param string $configPath
47+
* @param string[] $structures
48+
*/
49+
public function __construct(
50+
ObjectManagerInterface $objectManager,
51+
ScopeConfigInterface $scopeConfig,
52+
$configPath,
53+
array $structures = []
54+
) {
55+
$this->objectManager = $objectManager;
56+
$this->scopeConfig = $scopeConfig;
57+
$this->configPath = $configPath;
58+
$this->structures = $structures;
59+
}
60+
61+
/**
62+
* Create index structure
63+
*
64+
* @param array $data
65+
* @return IndexStructureInterface
66+
*/
67+
public function create(array $data = [])
68+
{
69+
$currentStructure = $this->scopeConfig->getValue($this->configPath, ScopeInterface::SCOPE_STORE);
70+
if (!isset($this->structures[$currentStructure])) {
71+
throw new \LogicException(
72+
'There is no such index structure: ' . $currentStructure
73+
);
74+
}
75+
$indexStructure = $this->objectManager->create($this->structures[$currentStructure], $data);
76+
77+
if (!$indexStructure instanceof IndexStructureInterface) {
78+
throw new \InvalidArgumentException(
79+
$indexStructure . ' doesn\'t implement \Magento\Framework\Indexer\IndexStructureInterface'
80+
);
81+
}
82+
83+
return $indexStructure;
84+
}
85+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\CatalogSearch\Model\Indexer;
7+
8+
use Magento\Framework\Indexer\IndexStructureInterface;
9+
10+
class IndexStructureProxy implements IndexStructureInterface
11+
{
12+
/**
13+
* @var IndexStructureInterface
14+
*/
15+
private $indexStructureEntity;
16+
17+
/**
18+
* @var IndexStructureFactory
19+
*/
20+
private $indexStructureFactory;
21+
22+
/**
23+
* @param IndexStructureFactory $indexStructureFactory
24+
*/
25+
public function __construct(
26+
IndexStructureFactory $indexStructureFactory
27+
) {
28+
$this->indexStructureFactory = $indexStructureFactory;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function delete(
35+
$index,
36+
array $dimensions = []
37+
) {
38+
return $this->getEntity()->delete($index, $dimensions);
39+
}
40+
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public function create(
45+
$index,
46+
array $fields,
47+
array $dimensions = []
48+
) {
49+
return $this->getEntity()->create($index, $fields, $dimensions);
50+
}
51+
52+
/**
53+
* Get instance of current index structure
54+
*
55+
* @return IndexStructureInterface
56+
*/
57+
private function getEntity()
58+
{
59+
if (empty($this->indexStructureEntity)) {
60+
$this->indexStructureEntity = $this->indexStructureFactory->create();
61+
}
62+
return $this->indexStructureEntity;
63+
}
64+
}

app/code/Magento/CatalogSearch/Model/Indexer/IndexerHandler.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\ResourceConnection;
1010
use Magento\Framework\DB\Adapter\AdapterInterface;
1111
use Magento\Framework\Indexer\SaveHandler\IndexerInterface;
12+
use Magento\Framework\Indexer\IndexStructureInterface;
1213
use Magento\Framework\Search\Request\Dimension;
1314
use Magento\Framework\Search\Request\IndexScopeResolverInterface;
1415
use Magento\Framework\Indexer\SaveHandler\Batch;
@@ -17,7 +18,7 @@
1718
class IndexerHandler implements IndexerInterface
1819
{
1920
/**
20-
* @var IndexStructure
21+
* @var IndexStructureInterface
2122
*/
2223
private $indexStructure;
2324

@@ -57,7 +58,7 @@ class IndexerHandler implements IndexerInterface
5758
private $indexScopeResolver;
5859

5960
/**
60-
* @param IndexStructure $indexStructure
61+
* @param IndexStructureInterface $indexStructure
6162
* @param ResourceConnection $resource
6263
* @param Config $eavConfig
6364
* @param Batch $batch
@@ -66,7 +67,7 @@ class IndexerHandler implements IndexerInterface
6667
* @param int $batchSize
6768
*/
6869
public function __construct(
69-
IndexStructure $indexStructure,
70+
IndexStructureInterface $indexStructure,
7071
ResourceConnection $resource,
7172
Config $eavConfig,
7273
Batch $batch,

app/code/Magento/CatalogSearch/etc/di.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
</argument>
2020
</arguments>
2121
</type>
22+
<type name="Magento\CatalogSearch\Model\Indexer\IndexStructureFactory">
23+
<arguments>
24+
<argument name="configPath" xsi:type="const">Magento\CatalogSearch\Model\ResourceModel\EngineInterface::CONFIG_ENGINE_PATH</argument>
25+
<argument name="structures" xsi:type="array">
26+
<item name="mysql" xsi:type="string">Magento\CatalogSearch\Model\Indexer\IndexStructure</item>
27+
</argument>
28+
</arguments>
29+
</type>
30+
<preference for="Magento\Framework\Indexer\IndexStructureInterface" type="Magento\CatalogSearch\Model\Indexer\IndexStructureProxy" />
2231
<type name="Magento\Framework\Search\Adapter\Mysql\Aggregation\DataProviderContainer">
2332
<arguments>
2433
<argument name="dataProviders" xsi:type="array">

app/code/Magento/Developer/Console/Command/XmlCatalogGenerateCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Symfony\Component\Console\Input\InputOption;
1313
use Symfony\Component\Console\Input\InputInterface;
1414
use Symfony\Component\Console\Output\OutputInterface;
15-
use Magento\Framework\App\Filesystem\DirectoryList;
1615

1716
/**
1817
* Class XmlCatalogGenerateCommand Generates dictionary of URNs for the IDE
@@ -42,9 +41,9 @@ class XmlCatalogGenerateCommand extends Command
4241
private $urnResolver;
4342

4443
/**
45-
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
44+
* @var \Magento\Framework\Filesystem\Directory\ReadFactory
4645
*/
47-
private $rootDirRead;
46+
private $readFactory;
4847

4948
/**
5049
* Supported formats
@@ -56,19 +55,19 @@ class XmlCatalogGenerateCommand extends Command
5655
/**
5756
* @param \Magento\Framework\App\Utility\Files $filesUtility
5857
* @param \Magento\Framework\Config\Dom\UrnResolver $urnResolver
59-
* @param \Magento\Framework\Filesystem $filesystemFactory
58+
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory
6059
* @param \Magento\Developer\Model\XmlCatalog\Format\FormatInterface[] $formats
6160
*/
6261
public function __construct(
6362
\Magento\Framework\App\Utility\Files $filesUtility,
6463
\Magento\Framework\Config\Dom\UrnResolver $urnResolver,
65-
\Magento\Framework\Filesystem $filesystemFactory,
64+
\Magento\Framework\Filesystem\Directory\ReadFactory $readFactory,
6665
array $formats = []
6766
) {
6867
$this->filesUtility = $filesUtility;
6968
$this->urnResolver = $urnResolver;
7069
$this->formats = $formats;
71-
$this->rootDirRead = $filesystemFactory->getDirectoryRead(DirectoryList::ROOT);
70+
$this->readFactory = $readFactory;
7271
parent::__construct();
7372
}
7473

@@ -111,9 +110,10 @@ private function getUrnDictionary(OutputInterface $output)
111110

112111
$urns = [];
113112
foreach ($files as $file) {
114-
$content = $this->rootDirRead->readFile(
115-
$this->rootDirRead->getRelativePath($file[0])
116-
);
113+
$fileDir = dirname($file[0]);
114+
$fileName = basename($file[0]);
115+
$read = $this->readFactory->create($fileDir);
116+
$content = $read->readFile($fileName);
117117
$matches = [];
118118
preg_match_all('/schemaLocation="(urn\:magento\:[^"]*)"/i', $content, $matches);
119119
if (isset($matches[1])) {

app/code/Magento/Developer/Test/Unit/Console/Command/XmlCatalogGenerateCommandTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,23 @@ public function testExecuteBadType()
4242
)->will($this->returnValue(null));
4343

4444
$formats = ['phpstorm' => $phpstormFormatMock];
45-
$filesystem = $this->getMock('Magento\Framework\Filesystem', [], [], '', false);
45+
$readFactory = $this->getMock('Magento\Framework\Filesystem\Directory\ReadFactory', [], [], '', false);
4646
$readDirMock = $this->getMock('\Magento\Framework\Filesystem\Directory\ReadInterface', [], [], '', false);
4747

4848
$content = file_get_contents($fixtureXmlFile);
4949

50-
$readDirMock->expects($this->once())
51-
->method('getRelativePath')
52-
->with($this->equalTo($fixtureXmlFile))
53-
->will($this->returnValue('test'));
5450
$readDirMock->expects($this->once())
5551
->method('readFile')
56-
->with($this->equalTo('test'))
52+
->with($this->equalTo('test.xml'))
5753
->will($this->returnValue($content));
58-
$filesystem->expects($this->once())
59-
->method('getDirectoryRead')
54+
$readFactory->expects($this->once())
55+
->method('create')
6056
->will($this->returnValue($readDirMock));
6157

6258
$this->command = new XmlCatalogGenerateCommand(
6359
$filesMock,
6460
$urnResolverMock,
65-
$filesystem,
61+
$readFactory,
6662
$formats
6763
);
6864

app/code/Magento/Payment/Model/CcConfigProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function getIcons()
5858
foreach (array_keys($types) as $code) {
5959
if (!array_key_exists($code, $icons)) {
6060
$asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png');
61-
$placeholder = $this->assetSource->findRelativeSourceFilePath($asset);
61+
$placeholder = $this->assetSource->findSource($asset);
6262
if ($placeholder) {
6363
list($width, $height) = getimagesize($asset->getSourceFile());
6464
$icons[$code] = [

app/code/Magento/Payment/Test/Unit/Model/CcConfigProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testGetConfig()
7777
[$ccAvailableTypesMock['ae']['fileId']]
7878
)->willReturn($assetMock);
7979
$this->assetSourceMock->expects($this->atLeastOnce())
80-
->method('findRelativeSourceFilePath')
80+
->method('findSource')
8181
->with($assetMock)
8282
->willReturnOnConsecutiveCalls(
8383
$ccAvailableTypesMock['vi']['path'],

dev/tests/integration/etc/install-config-mysql.travis.php.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
return [
88
'db-host' => '127.0.0.1',
9-
'db-user' => 'travis',
9+
'db-user' => 'root',
1010
'db-password' => '',
1111
'db-name' => 'magento_integration_tests',
1212
'db-prefix' => 'trv_',

dev/tests/integration/testsuite/Magento/Paypal/Model/Config/Structure/Reader/ReaderTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ public function testXmlConvertedConfigurationAndCompereStructure()
116116
*/
117117
protected function getActualContent()
118118
{
119-
$files = $this->fileUtility->getFiles(
120-
[$this->fileUtility->getPathToSource() . static::ACTUAL],
121-
'config.xml'
122-
);
119+
$files = $this->fileUtility->getFiles([BP . static::ACTUAL], 'config.xml');
123120

124121
return file_get_contents(reset($files));
125122
}
@@ -129,10 +126,7 @@ protected function getActualContent()
129126
*/
130127
protected function getExpectedContent()
131128
{
132-
$files = $this->fileUtility->getFiles(
133-
[$this->fileUtility->getPathToSource() . static::EXPECTED],
134-
'config.xml'
135-
);
129+
$files = $this->fileUtility->getFiles([BP . static::EXPECTED], 'config.xml');
136130

137131
return file_get_contents(reset($files));
138132
}

dev/tests/integration/testsuite/Magento/Setup/Console/Command/I18nCollectPhrasesCommandTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,22 @@ public function testExecuteNonExistingPath()
7575
]
7676
);
7777
}
78+
79+
/**
80+
* @expectedException \InvalidArgumentException
81+
* @expectedExceptionMessage Directory path is not needed when --magento flag is set.
82+
*/
83+
public function testExecuteMagentoFlagDirectoryPath()
84+
{
85+
$this->tester->execute(['directory' => 'a', '--magento' => true]);
86+
}
87+
88+
/**
89+
* @expectedException \InvalidArgumentException
90+
* @expectedExceptionMessage Directory path is needed when --magento flag is not set.
91+
*/
92+
public function testExecuteNoMagentoFlagNoDirectoryPath()
93+
{
94+
$this->tester->execute([]);
95+
}
7896
}

0 commit comments

Comments
 (0)