ltsecurityinc安防产品在线商城代码
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class DependenciesShowFrameworkCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var DependenciesShowFrameworkCommand
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $commandTester;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$modules = [
|
||||
'Magento_A' => __DIR__ . '/_files/root/app/code/Magento/A',
|
||||
'Magento_B' => __DIR__ . '/_files/root/app/code/Magento/B'
|
||||
];
|
||||
$objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
|
||||
$objectManager = $this->createMock(\Magento\Framework\App\ObjectManager::class);
|
||||
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
|
||||
|
||||
$themePackageListMock = $this->createMock(\Magento\Framework\View\Design\Theme\ThemePackageList::class);
|
||||
$componentRegistrarMock = $this->createMock(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$componentRegistrarMock->expects($this->any())->method('getPaths')->willReturn($modules);
|
||||
$dirSearchMock = $this->createMock(\Magento\Framework\Component\DirSearch::class);
|
||||
$dirSearchMock->expects($this->once())->method('collectFiles')->willReturn(
|
||||
[
|
||||
__DIR__ . '/_files/root/app/code/Magento/A/etc/module.xml',
|
||||
__DIR__ . '/_files/root/app/code/Magento/B/etc/module.xml'
|
||||
]
|
||||
);
|
||||
$objectManager->expects($this->any())->method('get')->willReturnMap([
|
||||
[\Magento\Framework\View\Design\Theme\ThemePackageList::class, $themePackageListMock],
|
||||
[\Magento\Framework\Component\ComponentRegistrar::class, $componentRegistrarMock],
|
||||
[\Magento\Framework\Component\DirSearch::class, $dirSearchMock]
|
||||
]);
|
||||
|
||||
$this->command = new DependenciesShowFrameworkCommand($componentRegistrarMock, $objectManagerProvider);
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists(__DIR__ . '/_files/output/framework.csv')) {
|
||||
unlink(__DIR__ . '/_files/output/framework.csv');
|
||||
}
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$this->commandTester->execute(
|
||||
['--output' => __DIR__ . '/_files/output/framework.csv']
|
||||
);
|
||||
$this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay());
|
||||
$fileContents = file_get_contents(__DIR__ . '/_files/output/framework.csv');
|
||||
$this->assertStringContainsString(
|
||||
'"Dependencies of framework:","Total number"' . PHP_EOL . ',2' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString('"Dependencies for each module:",' . PHP_EOL, $fileContents);
|
||||
$this->assertStringContainsString(
|
||||
'Magento\A,1' . PHP_EOL . '" -- Magento\Framework",2' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'Magento\B,1' . PHP_EOL . '" -- Magento\Framework",2' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class DependenciesShowModulesCircularCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var DependenciesShowModulesCircularCommand
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $commandTester;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$modules = [
|
||||
'Magento_A' => __DIR__ . '/_files/root/app/code/Magento/A',
|
||||
'Magento_B' => __DIR__ . '/_files/root/app/code/Magento/B'
|
||||
];
|
||||
|
||||
$objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
|
||||
$objectManager = $this->createMock(\Magento\Framework\App\ObjectManager::class);
|
||||
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
|
||||
|
||||
$themePackageListMock = $this->createMock(\Magento\Framework\View\Design\Theme\ThemePackageList::class);
|
||||
$componentRegistrarMock = $this->createMock(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$componentRegistrarMock->expects($this->any())->method('getPaths')->willReturn($modules);
|
||||
$dirSearchMock = $this->createMock(\Magento\Framework\Component\DirSearch::class);
|
||||
$objectManager->expects($this->any())->method('get')->willReturnMap([
|
||||
[\Magento\Framework\View\Design\Theme\ThemePackageList::class, $themePackageListMock],
|
||||
[\Magento\Framework\Component\ComponentRegistrar::class, $componentRegistrarMock],
|
||||
[\Magento\Framework\Component\DirSearch::class, $dirSearchMock]
|
||||
]);
|
||||
|
||||
$this->command = new DependenciesShowModulesCircularCommand($objectManagerProvider);
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists(__DIR__ . '/_files/output/circular.csv')) {
|
||||
unlink(__DIR__ . '/_files/output/circular.csv');
|
||||
}
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$this->commandTester->execute(
|
||||
['--output' => __DIR__ . '/_files/output/circular.csv']
|
||||
);
|
||||
$this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay());
|
||||
$fileContents = file_get_contents(__DIR__ . '/_files/output/circular.csv');
|
||||
$this->assertStringContainsString(
|
||||
'"Circular dependencies:","Total number of chains"' . PHP_EOL . ',2' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString('"Circular dependencies for each module:",' . PHP_EOL, $fileContents);
|
||||
$this->assertStringContainsString(
|
||||
'magento/module-a,1' . PHP_EOL . 'magento/module-a->magento/module-b->magento/module-a' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'magento/module-b,1' . PHP_EOL . 'magento/module-b->magento/module-a->magento/module-b' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class DependenciesShowModulesCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var DependenciesShowModulesCommand
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $commandTester;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
||||
$modules = [
|
||||
'Magento_A' => __DIR__ . '/_files/root/app/code/Magento/A',
|
||||
'Magento_B' => __DIR__ . '/_files/root/app/code/Magento/B'
|
||||
];
|
||||
|
||||
$objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
|
||||
$objectManager = $this->createMock(\Magento\Framework\App\ObjectManager::class);
|
||||
$objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
|
||||
|
||||
$themePackageListMock = $this->createMock(\Magento\Framework\View\Design\Theme\ThemePackageList::class);
|
||||
$componentRegistrarMock = $this->createMock(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$componentRegistrarMock->expects($this->any())->method('getPaths')->willReturn($modules);
|
||||
$dirSearchMock = $this->createMock(\Magento\Framework\Component\DirSearch::class);
|
||||
$objectManager->expects($this->any())->method('get')->willReturnMap([
|
||||
[\Magento\Framework\View\Design\Theme\ThemePackageList::class, $themePackageListMock],
|
||||
[\Magento\Framework\Component\ComponentRegistrar::class, $componentRegistrarMock],
|
||||
[\Magento\Framework\Component\DirSearch::class, $dirSearchMock]
|
||||
]);
|
||||
|
||||
$this->command = new DependenciesShowModulesCommand($objectManagerProvider);
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists(__DIR__ . '/_files/output/modules.csv')) {
|
||||
unlink(__DIR__ . '/_files/output/modules.csv');
|
||||
}
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$this->commandTester->execute(
|
||||
['--output' => __DIR__ . '/_files/output/modules.csv']
|
||||
);
|
||||
$this->assertEquals('Report successfully processed.' . PHP_EOL, $this->commandTester->getDisplay());
|
||||
$fileContents = file_get_contents(__DIR__ . '/_files/output/modules.csv');
|
||||
$this->assertStringContainsString(
|
||||
',All,Hard,Soft' . PHP_EOL . '"Total number of dependencies",2,2,0' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString('"Dependencies for each module:",All,Hard,Soft'. PHP_EOL, $fileContents);
|
||||
$this->assertStringContainsString(
|
||||
'magento/module-a,1,1,0' . PHP_EOL . '" -- magento/module-b",,1,0' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
$this->assertStringContainsString(
|
||||
'magento/module-b,1,1,0' . PHP_EOL . '" -- magento/module-a",,1,0' . PHP_EOL,
|
||||
$fileContents
|
||||
);
|
||||
}
|
||||
}
|
||||
+210
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Magento\Deploy\Console\DeployStaticOptions;
|
||||
use Magento\Framework\App\DeploymentConfig\FileReader;
|
||||
use Magento\Framework\App\DeploymentConfig\Writer;
|
||||
use Magento\Framework\App\DeploymentConfig\Writer\PhpFormatter;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\Config\File\ConfigFilePool;
|
||||
use Magento\Framework\Console\Cli;
|
||||
use Magento\Framework\Filesystem;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Store\Model\StoreManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Magento\Deploy\Console\ConsoleLoggerFactory;
|
||||
use Magento\Setup\Model\ObjectManagerProvider;
|
||||
use Magento\Deploy\Console\ConsoleLogger;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class DeployStaticContentCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $commandTester;
|
||||
|
||||
/**
|
||||
* @var Filesystem
|
||||
*/
|
||||
private $filesystem;
|
||||
|
||||
/**
|
||||
* @var ConfigFilePool
|
||||
*/
|
||||
private $configFilePool;
|
||||
|
||||
/**
|
||||
* @var FileReader
|
||||
*/
|
||||
private $reader;
|
||||
|
||||
/**
|
||||
* @var Writer
|
||||
*/
|
||||
private $writer;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $envConfig;
|
||||
|
||||
/**
|
||||
* @var StoreManagerInterface
|
||||
*/
|
||||
private $storeManager;
|
||||
|
||||
/**
|
||||
* @var PhpFormatter
|
||||
*/
|
||||
private $phpFormatter;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->reader = $this->objectManager->get(FileReader::class);
|
||||
$this->writer = $this->objectManager->get(Writer::class);
|
||||
$this->filesystem = $this->objectManager->get(Filesystem::class);
|
||||
$this->configFilePool = $this->objectManager->get(ConfigFilePool::class);
|
||||
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
|
||||
$this->phpFormatter = $this->objectManager->get(PhpFormatter::class);
|
||||
$this->config = $this->loadConfig();
|
||||
$this->envConfig = $this->loadEnvConfig();
|
||||
|
||||
$this->clearStaticFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
|
||||
$this->configFilePool->getPath(ConfigFilePool::APP_CONFIG),
|
||||
"<?php\n return [];\n"
|
||||
);
|
||||
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
|
||||
$this->configFilePool->getPath(ConfigFilePool::APP_ENV),
|
||||
"<?php\n return [];\n"
|
||||
);
|
||||
|
||||
$this->writer->saveConfig([ConfigFilePool::APP_CONFIG => $this->config]);
|
||||
$this->writer->saveConfig([ConfigFilePool::APP_ENV => $this->envConfig]);
|
||||
|
||||
$this->clearStaticFiles();
|
||||
$this->storeManager->reinitStores();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear pub/static and var/view_preprocessed directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function clearStaticFiles()
|
||||
{
|
||||
$this->filesystem->getDirectoryWrite(DirectoryList::PUB)->delete(DirectoryList::STATIC_VIEW);
|
||||
$this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR)->delete(DirectoryList::TMP_MATERIALIZATION_DIR);
|
||||
}
|
||||
|
||||
public function testDeployStaticWithoutDbConnection()
|
||||
{
|
||||
// emulate app:config:dump command
|
||||
$newData = array_replace_recursive(
|
||||
$this->config,
|
||||
require __DIR__ . '/_files/config/dump_config.php'
|
||||
);
|
||||
$this->writer->saveConfig([ConfigFilePool::APP_CONFIG => $newData], true);
|
||||
|
||||
// rewrite application environment config with only remote storage details to emulate work without db
|
||||
$this->filesystem->getDirectoryWrite(DirectoryList::CONFIG)->writeFile(
|
||||
$this->configFilePool->getPath(ConfigFilePool::APP_ENV),
|
||||
$this->phpFormatter->format(['remote_storage' => $this->envConfig['remote_storage']])
|
||||
);
|
||||
$this->storeManager->reinitStores();
|
||||
|
||||
$this->commandTester = new CommandTester($this->getStaticContentDeployCommand());
|
||||
$this->commandTester->execute(
|
||||
['--force' => 1, '--' . DeployStaticOptions::THEME => ['Magento/blank']]
|
||||
);
|
||||
$commandOutput = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertEquals(Cli::RETURN_SUCCESS, $this->commandTester->getStatusCode());
|
||||
$this->assertStringContainsString('Execution time:', $commandOutput);
|
||||
$this->assertStringContainsString('frontend/Magento/blank/en_US', $commandOutput);
|
||||
$this->assertStringNotContainsString('frontend/Magento/luma/en_US', $commandOutput);
|
||||
$this->assertStringNotContainsString('adminhtml/Magento/backend', $commandOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function loadConfig()
|
||||
{
|
||||
return $this->reader->load(ConfigFilePool::APP_CONFIG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function loadEnvConfig()
|
||||
{
|
||||
return $this->reader->load(ConfigFilePool::APP_ENV);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DeployStaticContentCommand instance with mocked loggers
|
||||
*
|
||||
* @return DeployStaticContentCommand
|
||||
*/
|
||||
private function getStaticContentDeployCommand()
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$consoleLoggerFactoryMock = $this->getMockBuilder(ConsoleLoggerFactory::class)
|
||||
->setMethods(['getLogger'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$consoleLoggerFactoryMock
|
||||
->method('getLogger')
|
||||
->willReturnCallback(
|
||||
function ($output) use ($objectManager) {
|
||||
return $objectManager->create(ConsoleLogger::class, ['output' => $output]);
|
||||
}
|
||||
);
|
||||
$objectManagerProviderMock = $this->getMockBuilder(ObjectManagerProvider::class)
|
||||
->setMethods(['get'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$objectManagerProviderMock
|
||||
->method('get')
|
||||
->willReturn(\Magento\TestFramework\Helper\Bootstrap::getObjectManager());
|
||||
$deployStaticContentCommand = $objectManager->create(
|
||||
DeployStaticContentCommand::class,
|
||||
[
|
||||
'consoleLoggerFactory' => $consoleLoggerFactoryMock,
|
||||
'objectManagerProvider' => $objectManagerProviderMock
|
||||
]
|
||||
);
|
||||
|
||||
return $deployStaticContentCommand;
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Magento\Framework\App\ObjectManagerFactory;
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\Console\Cli;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Indexer\Console\Command\IndexerReindexCommand;
|
||||
use Magento\Setup\Fixtures\FixtureModel;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* Class GenerateFixturesCommandCommandTest
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class GenerateFixturesCommandTest extends \Magento\TestFramework\Indexer\TestCase
|
||||
{
|
||||
/** @var CommandTester */
|
||||
private $indexerCommand;
|
||||
|
||||
/** @var FixtureModel */
|
||||
private $fixtureModelMock;
|
||||
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var GenerateFixturesCommand */
|
||||
private $command;
|
||||
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
$this->objectManager->get(\Magento\TestFramework\App\Config::class)->clean();
|
||||
|
||||
$this->fixtureModelMock = $this->getMockBuilder(FixtureModel::class)
|
||||
->setMethods(['getObjectManager'])
|
||||
->setConstructorArgs([$this->objectManager->get(IndexerReindexCommand::class)])
|
||||
->getMock();
|
||||
$this->fixtureModelMock
|
||||
->method('getObjectManager')
|
||||
->willReturn($this->objectManager);
|
||||
|
||||
$this->command = $this->objectManager->create(
|
||||
GenerateFixturesCommand::class,
|
||||
[
|
||||
'fixtureModel' => $this->fixtureModelMock
|
||||
]
|
||||
);
|
||||
|
||||
$objectFactoryMock = $this->getMockBuilder(ObjectManagerFactory::class)
|
||||
->setMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$objectFactoryMock
|
||||
->method('create')
|
||||
->willReturn($this->objectManager);
|
||||
|
||||
$this->indexerCommand = new CommandTester($this->objectManager->create(
|
||||
IndexerReindexCommand::class,
|
||||
['objectManagerFactory' => $objectFactoryMock]
|
||||
));
|
||||
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
|
||||
$this->setIncrement(3);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* teardown
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->setIncrement(1);
|
||||
|
||||
self::restoreFromDb();
|
||||
self::$dbRestored = true;
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$db = Bootstrap::getInstance()->getBootstrap()
|
||||
->getApplication()
|
||||
->getDbInstance();
|
||||
if (!$db->isDbDumpExists()) {
|
||||
throw new \LogicException('DB dump does not exist.');
|
||||
}
|
||||
$db->restoreFromDbDump();
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testExecute()
|
||||
{
|
||||
$profile = realpath(__DIR__ . "/_files/min_profile.xml");
|
||||
$this->commandTester->execute(
|
||||
[
|
||||
GenerateFixturesCommand::PROFILE_ARGUMENT => $profile,
|
||||
'--' . GenerateFixturesCommand::SKIP_REINDEX_OPTION => true
|
||||
]
|
||||
);
|
||||
$this->indexerCommand->execute([]);
|
||||
|
||||
static::assertEquals(
|
||||
Cli::RETURN_SUCCESS,
|
||||
$this->indexerCommand->getStatusCode(),
|
||||
$this->indexerCommand->getDisplay(true)
|
||||
);
|
||||
|
||||
static::assertEquals(
|
||||
Cli::RETURN_SUCCESS,
|
||||
$this->commandTester->getStatusCode(),
|
||||
$this->commandTester->getDisplay(true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
*/
|
||||
private function setIncrement($value)
|
||||
{
|
||||
/** @var \Magento\Framework\DB\Adapter\AdapterInterface $db */
|
||||
$db = Bootstrap::getObjectManager()->get(ResourceConnection::class)->getConnection();
|
||||
$db->query("SET @@session.auto_increment_increment=$value");
|
||||
$db->query("SET @@session.auto_increment_offset=$value");
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
class I18nCollectPhrasesCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var I18nCollectPhrasesCommand
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $tester;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->command = new I18nCollectPhrasesCommand();
|
||||
$this->tester = new CommandTester($this->command);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$property = new \ReflectionProperty(\Magento\Setup\Module\I18n\ServiceLocator::class, '_dictionaryGenerator');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue(null);
|
||||
$property->setAccessible(false);
|
||||
}
|
||||
|
||||
public function testExecuteConsoleOutput()
|
||||
{
|
||||
$this->tester->execute(
|
||||
[
|
||||
'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/',
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('Dictionary successfully processed.' . PHP_EOL, $this->tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testExecuteCsvOutput()
|
||||
{
|
||||
$outputPath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/output/phrases.csv';
|
||||
$this->tester->execute(
|
||||
[
|
||||
'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/phrases/',
|
||||
'--output' => $outputPath,
|
||||
]
|
||||
);
|
||||
|
||||
$handle = fopen($outputPath, 'r');
|
||||
$output = fread($handle, filesize($outputPath));
|
||||
$expected = file_get_contents(
|
||||
BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/expectedPhrases.csv'
|
||||
);
|
||||
$this->assertEquals($expected, $output);
|
||||
unlink($outputPath);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testExecuteNonExistingPath()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Specified path doesn\'t exist');
|
||||
|
||||
$this->tester->execute(
|
||||
[
|
||||
'directory' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/non_exist',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testExecuteMagentoFlagDirectoryPath()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Directory path is not needed when --magento flag is set.');
|
||||
|
||||
$this->tester->execute(['directory' => 'a', '--magento' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testExecuteNoMagentoFlagNoDirectoryPath()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Directory path is needed when --magento flag is not set.');
|
||||
|
||||
$this->tester->execute([]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
|
||||
/**
|
||||
* @magentoComponentsDir Magento/Setup/Console/Command/_files/root/app/code
|
||||
*/
|
||||
class I18nPackCommandTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var I18nCollectPhrasesCommand
|
||||
*/
|
||||
private $command;
|
||||
|
||||
/**
|
||||
* @var CommandTester
|
||||
*/
|
||||
private $tester;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->command = new I18nPackCommand();
|
||||
$this->tester = new CommandTester($this->command);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$this->removeCsv('A');
|
||||
$this->removeCsv('B');
|
||||
$this->removeCsv('C');
|
||||
$this->removeCsv('D');
|
||||
}
|
||||
|
||||
private function removeCsv($module)
|
||||
{
|
||||
if (file_exists(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n")) {
|
||||
$helper = new \Magento\Framework\Backup\Filesystem\Helper();
|
||||
$helper->rm(__DIR__ . "/_files/root/app/code/Magento/{$module}/i18n", [], true);
|
||||
}
|
||||
}
|
||||
|
||||
public function testExecute()
|
||||
{
|
||||
$this->tester->execute(
|
||||
[
|
||||
'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
|
||||
'locale' => 'de_DE',
|
||||
'--allow-duplicates' => true,
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('Successfully saved de_DE language package.' . PHP_EOL, $this->tester->getDisplay());
|
||||
$basePath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/root/app/code';
|
||||
$this->assertFileExists($basePath . '/Magento/A/i18n/de_DE.csv');
|
||||
$this->assertFileExists($basePath . '/Magento/B/i18n/de_DE.csv');
|
||||
$this->assertFileExists($basePath . '/Magento/C/i18n/de_DE.csv');
|
||||
$this->assertFileExists($basePath . '/Magento/D/i18n/de_DE.csv');
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testExecuteNonExistingPath()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Cannot open dictionary file:');
|
||||
|
||||
$nonExistPath = BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/non_exist.csv';
|
||||
$this->tester->execute(
|
||||
[
|
||||
'source' => $nonExistPath,
|
||||
'locale' => 'de_DE',
|
||||
'--allow-duplicates' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testExecuteInvalidMode()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Possible values for \'mode\' option are \'replace\' and \'merge\'');
|
||||
|
||||
$this->tester->execute(
|
||||
[
|
||||
'source' => BP . '/dev/tests/integration/testsuite/Magento/Setup/Console/Command/_files/i18n.csv',
|
||||
'locale' => 'de_DE',
|
||||
'--allow-duplicates' => true,
|
||||
'--mode' => 'invalid'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Console\Command;
|
||||
|
||||
use Magento\Catalog\Model\Indexer\Product\Price\DimensionModeConfiguration;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Magento\Framework\Console\Cli;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* Test command that sets indexer mode for catalog_product_price indexer
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class PriceIndexerDimensionsModeSetCommandTest extends \Magento\TestFramework\Indexer\TestCase
|
||||
{
|
||||
/** @var ObjectManagerInterface */
|
||||
private $objectManager;
|
||||
|
||||
/** @var \Magento\Indexer\Console\Command\IndexerSetDimensionsModeCommand */
|
||||
private $command;
|
||||
|
||||
/** @var CommandTester */
|
||||
private $commandTester;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
|
||||
$this->objectManager->get(\Magento\TestFramework\App\Config::class)->clean();
|
||||
|
||||
$this->command = $this->objectManager->create(
|
||||
\Magento\Indexer\Console\Command\IndexerSetDimensionsModeCommand::class
|
||||
);
|
||||
|
||||
$this->commandTester = new CommandTester($this->command);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* setUpBeforeClass
|
||||
*/
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$db = Bootstrap::getInstance()->getBootstrap()
|
||||
->getApplication()
|
||||
->getDbInstance();
|
||||
if (!$db->isDbDumpExists()) {
|
||||
throw new \LogicException('DB dump does not exist.');
|
||||
}
|
||||
$db->restoreFromDbDump();
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoAppIsolation enabled
|
||||
*
|
||||
* @param string $previousMode
|
||||
* @param string $currentMode
|
||||
* @dataProvider modesDataProvider
|
||||
*/
|
||||
public function testSwitchMode($previousMode, $currentMode)
|
||||
{
|
||||
$this->commandTester->execute(
|
||||
[
|
||||
'indexer' => 'catalog_product_price',
|
||||
'mode' => $currentMode,
|
||||
]
|
||||
);
|
||||
$expectedOutput = 'Dimensions mode for indexer "Product Price" was changed from \''
|
||||
. $previousMode . '\' to \'' . $currentMode . '\'' . PHP_EOL;
|
||||
|
||||
$actualOutput = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertStringContainsString($expectedOutput, $actualOutput);
|
||||
|
||||
static::assertEquals(
|
||||
Cli::RETURN_SUCCESS,
|
||||
$this->commandTester->getStatusCode(),
|
||||
$this->commandTester->getDisplay(true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Modes data provider
|
||||
* @return array
|
||||
*/
|
||||
public function modesDataProvider()
|
||||
{
|
||||
return [
|
||||
[DimensionModeConfiguration::DIMENSION_NONE, DimensionModeConfiguration::DIMENSION_WEBSITE],
|
||||
[DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP],
|
||||
[
|
||||
DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP,
|
||||
DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP
|
||||
],
|
||||
[
|
||||
DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP,
|
||||
DimensionModeConfiguration::DIMENSION_NONE
|
||||
],
|
||||
[
|
||||
DimensionModeConfiguration::DIMENSION_NONE,
|
||||
DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP
|
||||
],
|
||||
[
|
||||
DimensionModeConfiguration::DIMENSION_WEBSITE_AND_CUSTOMER_GROUP,
|
||||
DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP
|
||||
],
|
||||
[DimensionModeConfiguration::DIMENSION_CUSTOMER_GROUP, DimensionModeConfiguration::DIMENSION_WEBSITE],
|
||||
[DimensionModeConfiguration::DIMENSION_WEBSITE, DimensionModeConfiguration::DIMENSION_NONE],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testSwitchModeForSameMode()
|
||||
{
|
||||
$this->commandTester->execute(
|
||||
[
|
||||
'indexer' => 'catalog_product_price',
|
||||
'mode' => DimensionModeConfiguration::DIMENSION_NONE
|
||||
]
|
||||
);
|
||||
$expectedOutput = 'Dimensions mode for indexer "Product Price" has not been changed' . PHP_EOL;
|
||||
|
||||
$actualOutput = $this->commandTester->getDisplay();
|
||||
|
||||
$this->assertStringContainsString($expectedOutput, $actualOutput);
|
||||
|
||||
static::assertEquals(
|
||||
Cli::RETURN_SUCCESS,
|
||||
$this->commandTester->getStatusCode(),
|
||||
$this->commandTester->getDisplay(true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoAppIsolation enabled
|
||||
*
|
||||
*/
|
||||
public function testSwitchModeWithInvalidArgument()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->commandTester->execute(
|
||||
[
|
||||
'indexer' => 'indexer_not_valid'
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
return [
|
||||
'scopes' => [
|
||||
'websites' => [
|
||||
'admin' => [
|
||||
'website_id' => '0',
|
||||
'code' => 'admin',
|
||||
'name' => 'Admin',
|
||||
'sort_order' => '0',
|
||||
'default_group_id' => '0',
|
||||
'is_default' => '0',
|
||||
],
|
||||
'base' => [
|
||||
'website_id' => '1',
|
||||
'code' => 'base',
|
||||
'name' => 'Main Website',
|
||||
'sort_order' => '0',
|
||||
'default_group_id' => '1',
|
||||
'is_default' => '1',
|
||||
],
|
||||
],
|
||||
'groups' => [
|
||||
0 => [
|
||||
'group_id' => '0',
|
||||
'website_id' => '0',
|
||||
'code' => 'default',
|
||||
'name' => 'Default',
|
||||
'root_category_id' => '0',
|
||||
'default_store_id' => '0',
|
||||
],
|
||||
1 => [
|
||||
'group_id' => '1',
|
||||
'website_id' => '1',
|
||||
'code' => 'main_website_store',
|
||||
'name' => 'Main Website Store',
|
||||
'root_category_id' => '2',
|
||||
'default_store_id' => '1',
|
||||
],
|
||||
],
|
||||
'stores' => [
|
||||
'admin' => [
|
||||
'store_id' => '0',
|
||||
'code' => 'admin',
|
||||
'website_id' => '0',
|
||||
'group_id' => '0',
|
||||
'name' => 'Admin',
|
||||
'sort_order' => '0',
|
||||
'is_active' => '1',
|
||||
],
|
||||
'default' => [
|
||||
'store_id' => '1',
|
||||
'code' => 'default',
|
||||
'website_id' => '1',
|
||||
'group_id' => '1',
|
||||
'name' => 'Default Store View',
|
||||
'sort_order' => '0',
|
||||
'is_active' => '1',
|
||||
],
|
||||
],
|
||||
],
|
||||
'themes' => [
|
||||
'adminhtml/Magento/backend' => [
|
||||
'parent_id' => null,
|
||||
'theme_path' => 'Magento/backend',
|
||||
'theme_title' => 'Magento 2 backend',
|
||||
'is_featured' => '0',
|
||||
'area' => 'adminhtml',
|
||||
'type' => '0',
|
||||
'code' => 'Magento/backend',
|
||||
],
|
||||
'frontend/Magento/blank' => [
|
||||
'parent_id' => null,
|
||||
'theme_path' => 'Magento/blank',
|
||||
'theme_title' => 'Magento Blank',
|
||||
'is_featured' => '0',
|
||||
'area' => 'frontend',
|
||||
'type' => '0',
|
||||
'code' => 'Magento/blank',
|
||||
],
|
||||
'frontend/Magento/luma' => [
|
||||
'parent_id' => 'Magento/blank',
|
||||
'theme_path' => 'Magento/luma',
|
||||
'theme_title' => 'Magento Luma',
|
||||
'is_featured' => '0',
|
||||
'area' => 'frontend',
|
||||
'type' => '0',
|
||||
'code' => 'Magento/luma',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
ce
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"simple text","simple text"
|
||||
"simple text with 1 string literal placeholder %1","simple text with 1 string literal placeholder %1"
|
||||
"simple text with 1 variable placeholder %1","simple text with 1 variable placeholder %1"
|
||||
"simple text with multiple placeholders %1 %2","simple text with multiple placeholders %1 %2"
|
||||
"first part second part","first part second part"
|
||||
"first part second part third part","first part second part third part"
|
||||
"first part second part with one string literal placeholder %1","first part second part with one string literal placeholder %1"
|
||||
"first part of concat second part with one variable placeholder %1","first part of concat second part with one variable placeholder %1"
|
||||
"first part of concat second part with two placeholders %1, %2","first part of concat second part with two placeholders %1, %2"
|
||||
"first part of concat second part third part with one placeholder %1","first part of concat second part third part with one placeholder %1"
|
||||
"first part of concat second part third part with two placeholders %1, %2","first part of concat second part third part with two placeholders %1, %2"
|
||||
"string with escaped 'single quotes'","string with escaped 'single quotes'"
|
||||
"string with placeholder in escaped single quotes '%1'","string with placeholder in escaped single quotes '%1'"
|
||||
"string with ""double quotes""","string with ""double quotes"""
|
||||
"string with placeholder in double quotes ""%1""","string with placeholder in double quotes ""%1"""
|
||||
"string with 'single quotes'","string with 'single quotes'"
|
||||
"string with placeholder in single quotes '%1'","string with placeholder in single quotes '%1'"
|
||||
"string with escaped ""double quotes""","string with escaped ""double quotes"""
|
||||
"string with placeholder in escaped double quotes ""%1""","string with placeholder in escaped double quotes ""%1"""
|
||||
"string that's got an unclosed single quote in it","string that's got an unclosed single quote in it"
|
||||
"Thank you for your order from %store_name.","Thank you for your order from %store_name."
|
||||
"Our hours are <span class=""no-link"">%store_hours</span>.","Our hours are <span class=""no-link"">%store_hours</span>."
|
||||
"Translation inside if directive","Translation inside if directive"
|
||||
"Test di text","Test di text"
|
||||
|
@@ -0,0 +1,9 @@
|
||||
"Read Details","Read Details",module,Magento_A
|
||||
"Mark as Read","Mark as Read",module,Magento_A
|
||||
"Are you sure?","Are you sure?",module,"Magento_A,Magento_B,Magento_C"
|
||||
"Messages Inbox","Messages Inbox",module,Magento_D
|
||||
"You have %1 new system messages","You have %1 new system messages",module,Magento_A
|
||||
"You have %1 new system message","You have %1 new system message",module,Magento_B
|
||||
"Incoming Message","Incoming Message",module,Magento_C
|
||||
close,close,module,"Magento_B,Magento_C"
|
||||
"Read details","Read details",module,Magento_D
|
||||
|
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<profile>
|
||||
<admin_users>2</admin_users><!-- Number of admin users to generate -->
|
||||
<websites>1</websites> <!-- Number of websites to generate -->
|
||||
<store_groups>1</store_groups> <!--Number of stores-->
|
||||
<store_views>1</store_views> <!-- Number of store views -->
|
||||
<assign_entities_to_all_websites>0</assign_entities_to_all_websites> <!-- Whether to assign all products per each website -->
|
||||
<simple_products>1</simple_products> <!-- Simple products count -->
|
||||
<configurable_products> <!-- Configurable product -->
|
||||
<config>
|
||||
<attributes>
|
||||
<attribute>
|
||||
<options>3</options>
|
||||
<swatches>image</swatches>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<options>8</options>
|
||||
</attribute>
|
||||
</attributes>
|
||||
<sku>Configurable Product %s</sku>
|
||||
<products>16</products>
|
||||
</config>
|
||||
</configurable_products>
|
||||
<product-images>
|
||||
<images-count>1</images-count>
|
||||
<images-per-product>1</images-per-product>
|
||||
</product-images>
|
||||
<categories>1</categories> <!-- Number of categories to generate -->
|
||||
<categories_nesting_level>1</categories_nesting_level> <!-- Nesting level for categories -->
|
||||
<customers>1</customers> <!-- Number of customers to generate -->
|
||||
|
||||
<catalog_price_rules>1</catalog_price_rules> <!-- Number of catalog price rules -->
|
||||
<cart_price_rules>1</cart_price_rules> <!-- Number of cart price rules -->
|
||||
<cart_price_rules_floor>1</cart_price_rules_floor>
|
||||
<coupon_codes>1</coupon_codes> <!-- Number of coupon codes -->
|
||||
|
||||
<product_attribute_sets>1</product_attribute_sets> <!-- Number of product attribute sets -->
|
||||
<product_attribute_sets_attributes>1</product_attribute_sets_attributes> <!-- Number of attributes per set -->
|
||||
<product_attribute_sets_attributes_values>1</product_attribute_sets_attributes_values> <!-- Number of values per attribute -->
|
||||
|
||||
<order_quotes_enable>true</order_quotes_enable>
|
||||
<order_simple_product_count_from>1</order_simple_product_count_from>
|
||||
<order_simple_product_count_to>1</order_simple_product_count_to>
|
||||
<orders>1</orders> <!-- Orders count -->
|
||||
|
||||
<tax_rates_file>tax_rates_small.csv</tax_rates_file> <!-- Tax rates file in fixtures directory-->
|
||||
|
||||
<configs> <!-- Config variables and values for change -->
|
||||
<config>
|
||||
<path>admin/security/use_form_key</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>0</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>admin/security/session_lifetime</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>7200</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>admin/security/admin_account_sharing</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>1</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>carriers/flatrate/active</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>1</value>
|
||||
</config>
|
||||
</configs>
|
||||
<indexers> <!-- Indexer mode value (true - Update by Schedule, false - Update on Save) -->
|
||||
<indexer>
|
||||
<id>catalog_category_product</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_category</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_price</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_attribute</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>cataloginventory_stock</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogrule_rule</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogrule_product</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogsearch_fulltext</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
</indexers>
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/searchTermsLarge.xml" />
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/attributeSets.xml" />
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/searchConfig.xml" />
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/customerConfig.xml" />
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/description.xml" />
|
||||
<xi:include href="../../../../../../../../../setup/performance-toolkit/config/shortDescription.xml" />
|
||||
</profile>
|
||||
</config>
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/***
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Phrase;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD)
|
||||
* @codingStandardsIgnoreStart
|
||||
*/
|
||||
class TestPhrases
|
||||
{
|
||||
public function awesomeFunction()
|
||||
{
|
||||
$str1 = 'str1';
|
||||
$str2 = 'str2';
|
||||
|
||||
// Simple
|
||||
$simpleCases = [
|
||||
new Phrase('simple text'),
|
||||
new Phrase('simple text with 1 string literal placeholder %1', 'arg'),
|
||||
new Phrase('simple text with 1 variable placeholder %1', $str1),
|
||||
new Phrase('simple text with multiple placeholders %1 %2', $str1, $str2),
|
||||
];
|
||||
|
||||
// Phrase objects
|
||||
$phraseObjects = [
|
||||
// Single concatenation
|
||||
new Phrase('first part'
|
||||
. ' second part'),
|
||||
new Phrase('first part' . ' second part' . ' third part'),
|
||||
|
||||
// Multiple concatenation
|
||||
new Phrase('first part' . ' second part with one string literal placeholder %1', 'arg'),
|
||||
new Phrase('first part of concat' . ' second part with one variable placeholder %1', $str1),
|
||||
new Phrase('first part of concat' . ' second part with two placeholders %1, %2', $str1, $str2),
|
||||
new Phrase('first part of concat' . ' second part' . ' third part with one placeholder %1', 'arg'),
|
||||
new Phrase(
|
||||
'first part of concat' . ' second part' . ' third part with two placeholders %1, %2',
|
||||
$str1,
|
||||
$str2
|
||||
),
|
||||
|
||||
// Escaped quotes
|
||||
new Phrase('string with escaped \'single quotes\''),
|
||||
new Phrase('string with placeholder in escaped single quotes \'%1\'', 'arg'),
|
||||
new Phrase('string with "double quotes"'),
|
||||
new Phrase('string with placeholder in double quotes "%1"', 'arg'),
|
||||
];
|
||||
|
||||
$singleQuoteTranslateFunctions = [
|
||||
// Single concatenation
|
||||
__('first part' . ' second part'),
|
||||
__('first part' . ' second part' . ' third part'),
|
||||
|
||||
// Multiple concatenation
|
||||
__('first part' . ' second part with one string literal placeholder %1', 'arg'),
|
||||
__('first part of concat' . ' second part with one variable placeholder %1', $str1),
|
||||
__('first part of concat' . ' second part with two placeholders %1, %2', $str1, $str2),
|
||||
__('first part of concat' . ' second part' . ' third part with one placeholder %1', 'arg'),
|
||||
__('first part of concat' . ' second part' . ' third part with two placeholders %1, %2', $str1, $str2),
|
||||
|
||||
// Escaped quotes
|
||||
__('string with escaped \'single quotes\''),
|
||||
__('string with placeholder in escaped single quotes \'%1\'', 'arg'),
|
||||
__('string with "double quotes"'),
|
||||
__('string with placeholder in double quotes "%1"', 'arg'),
|
||||
];
|
||||
|
||||
$doubleQuoteTranslateFunctions = [
|
||||
// Single concatenation
|
||||
__("first part" . " second part"),
|
||||
__("first part" . " second part" . " third part"),
|
||||
|
||||
// Multiple concatenation
|
||||
__("first part" . " second part with one string literal placeholder %1", "arg"),
|
||||
__("first part of concat" . " second part with one variable placeholder %1", $str1),
|
||||
__("first part of concat" . " second part with two placeholders %1, %2", $str1, $str2),
|
||||
__("first part of concat" . " second part" . " third part with one placeholder %1", "arg"),
|
||||
__("first part of concat" . " second part" . " third part with two placeholders %1, %2", $str1, $str2),
|
||||
|
||||
// Escaped quotes
|
||||
__("string with 'single quotes'"),
|
||||
__("string with placeholder in single quotes '%1'", "arg"),
|
||||
__("string with escaped \"double quotes\""),
|
||||
__("string with placeholder in escaped double quotes \"%1\"", "arg"),
|
||||
];
|
||||
|
||||
$unclosedApostrophePhrase = __('string that\'s got an unclosed single quote in it');
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
|
||||
<type name="TestName">
|
||||
<arguments>
|
||||
<argument name="test" xsi:type="array">
|
||||
<item name="test" xsi:type="string" translatable="true">Test di text</item>
|
||||
</argument>
|
||||
</arguments>
|
||||
</type>
|
||||
</config>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
|
||||
{{template config_path="design/email/header_template"}}
|
||||
|
||||
<table>
|
||||
<tr class="email-intro">
|
||||
<td>
|
||||
<p>
|
||||
{{trans "Thank you for your order from %store_name." store_name=$store.frontend_name}}
|
||||
</p>
|
||||
<p>
|
||||
{{depend store_hours}}
|
||||
{{trans 'Our hours are <span class="no-link">%store_hours</span>.' store_hours=$store_hours |raw}}
|
||||
{{/depend}}
|
||||
</p>
|
||||
{{if something}}
|
||||
<p>{{trans 'Translation inside if directive'}}</p>
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{{template config_path="design/email/footer_template"}}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\A\Model;
|
||||
|
||||
class Foo
|
||||
{
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
||||
*/
|
||||
public function foo()
|
||||
{
|
||||
$frameworkDependencies = new \Magento\Framework\A();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "magento/module-a",
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.4.0||~8.0.0",
|
||||
"magento/framework": "0.1",
|
||||
"magento/module-b": "0.1"
|
||||
},
|
||||
"version": "0.1"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_A" />
|
||||
</config>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_A', __DIR__);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\B\Model;
|
||||
|
||||
class Foo
|
||||
{
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
||||
*/
|
||||
public function foo()
|
||||
{
|
||||
$frameworkDependencies = new \Magento\Framework\B();
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "magento/module-b",
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.4.0||~8.0.0",
|
||||
"magento/framework": "*",
|
||||
"magento/module-a": "0.1"
|
||||
},
|
||||
"version": "0.1"
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_B" />
|
||||
</config>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_B', __DIR__);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_C', __DIR__);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_D', __DIR__);
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Framework\Test\Unit\View\Element;
|
||||
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
|
||||
use Magento\Framework\View\Element\UiComponent\DataProvider\Sanitizer;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class UiComponentFactoryTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/** @var \Magento\Framework\View\Element\UiComponentFactory */
|
||||
protected $model;
|
||||
|
||||
/** @var ObjectManagerHelper */
|
||||
protected $objectManagerHelper;
|
||||
|
||||
/** @var \Magento\Framework\ObjectManagerInterface|MockObject */
|
||||
protected $objectManagerMock;
|
||||
|
||||
/** @var \Magento\Framework\Data\Argument\InterpreterInterface|MockObject */
|
||||
protected $interpreterMock;
|
||||
|
||||
/** @var \Magento\Framework\View\Element\UiComponent\ContextFactory|MockObject */
|
||||
protected $contextFactoryMock;
|
||||
|
||||
/** @var \Magento\Framework\Config\DataInterfaceFactory|MockObject */
|
||||
protected $dataInterfaceFactoryMock;
|
||||
|
||||
/** @var \Magento\Ui\Config\Reader\Definition\Data|MockObject */
|
||||
protected $dataMock;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
|
||||
->getMockForAbstractClass();
|
||||
$this->interpreterMock = $this->getMockBuilder(\Magento\Framework\Data\Argument\InterpreterInterface::class)
|
||||
->getMockForAbstractClass();
|
||||
$this->contextFactoryMock = $this
|
||||
->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextFactory::class)
|
||||
->setMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->dataInterfaceFactoryMock = $this->getMockBuilder(\Magento\Framework\Config\DataInterfaceFactory::class)
|
||||
->setMethods(['create'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->dataMock = $this->createMock(\Magento\Framework\Config\DataInterface::class);
|
||||
$sanitizerMock = $this->createMock(Sanitizer::class);
|
||||
$sanitizerMock->method('sanitize')->willReturnArgument(0);
|
||||
$sanitizerMock->method('sanitizeComponentMetadata')->willReturnArgument(0);
|
||||
$this->objectManagerHelper = new ObjectManagerHelper($this);
|
||||
$this->model = $this->objectManagerHelper->getObject(
|
||||
\Magento\Framework\View\Element\UiComponentFactory::class,
|
||||
[
|
||||
'objectManager' => $this->objectManagerMock,
|
||||
'argumentInterpreter' => $this->interpreterMock,
|
||||
'contextFactory' => $this->contextFactoryMock,
|
||||
'configFactory' => $this->dataInterfaceFactoryMock,
|
||||
'data' => [],
|
||||
'componentChildFactories' => [],
|
||||
'definitionData' => $this->dataMock,
|
||||
'sanitizer' => $sanitizerMock
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testCreateRootComponent()
|
||||
{
|
||||
$identifier = "product_listing";
|
||||
$context = $this->createMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class);
|
||||
$bundleComponents = [
|
||||
'attributes' => [
|
||||
'class' => 'Some\Class\Component',
|
||||
],
|
||||
'arguments' => [
|
||||
'config' => [
|
||||
'class' => 'Some\Class\Component2'
|
||||
]
|
||||
],
|
||||
'children' => []
|
||||
];
|
||||
$uiConfigMock = $this->createMock(\Magento\Framework\Config\DataInterface::class);
|
||||
$this->dataInterfaceFactoryMock->expects($this->once())
|
||||
->method('create')
|
||||
->willReturn($uiConfigMock);
|
||||
$uiConfigMock->expects($this->once())
|
||||
->method('get')
|
||||
->willReturn($bundleComponents);
|
||||
|
||||
$this->contextFactoryMock->expects($this->once())
|
||||
->method('create')
|
||||
->willReturn($context);
|
||||
$expectedArguments = [
|
||||
'config' => [
|
||||
'class' => 'Some\Class\Component2'
|
||||
],
|
||||
'data' => [
|
||||
'name' => $identifier
|
||||
],
|
||||
'context' => $context,
|
||||
'components' => []
|
||||
];
|
||||
$this->objectManagerMock->expects($this->once())
|
||||
->method('create')
|
||||
->with('Some\Class\Component2', $expectedArguments);
|
||||
$this->model->create($identifier);
|
||||
}
|
||||
|
||||
public function testNonRootComponent()
|
||||
{
|
||||
$identifier = "custom_select";
|
||||
$name = "fieldset";
|
||||
$context = $this->createMock(\Magento\Framework\View\Element\UiComponent\ContextInterface::class);
|
||||
$arguments = ['context' => $context];
|
||||
$definitionArguments = [
|
||||
'componentType' => 'select',
|
||||
'attributes' => [
|
||||
'class' => '\Some\Class',
|
||||
],
|
||||
'arguments' => []
|
||||
];
|
||||
$expectedArguments = [
|
||||
'data' => [
|
||||
'name' => $identifier
|
||||
],
|
||||
'context' => $context,
|
||||
'components' => []
|
||||
];
|
||||
$this->dataMock->expects($this->once())
|
||||
->method('get')
|
||||
->with($name)
|
||||
->willReturn($definitionArguments);
|
||||
$this->objectManagerMock->expects($this->once())
|
||||
->method('create')
|
||||
->with('\Some\Class', $expectedArguments);
|
||||
$this->model->create($identifier, $name, $arguments);
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Setup\Declaration;
|
||||
|
||||
use Magento\Framework\App\ResourceConnection;
|
||||
use Magento\Framework\App\Utility\Files;
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Magento\Framework\Component\ComponentRegistrarInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\Setup\Declaration\Schema\Dto\Constraint;
|
||||
use Magento\Framework\Setup\Declaration\Schema\Dto\Index;
|
||||
use Magento\Framework\Setup\Declaration\Schema\SchemaConfigInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
use Magento\TestFramework\ObjectManager;
|
||||
|
||||
/**
|
||||
* Checks whitelisted tables behaviour
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
class WhitelistDeclarationTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ComponentRegistrarInterface
|
||||
*/
|
||||
private $componentRegistrar;
|
||||
|
||||
/**
|
||||
* @var SchemaConfigInterface
|
||||
*/
|
||||
private $schemaConfig;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
/** @var ObjectManagerInterface|ObjectManager $objectManager */
|
||||
$objectManager = Bootstrap::getObjectManager();
|
||||
$resourceConnection = $objectManager->create(ResourceConnection::class);
|
||||
$objectManager->removeSharedInstance(ResourceConnection::class);
|
||||
$objectManager->addSharedInstance($resourceConnection, ResourceConnection::class);
|
||||
$this->componentRegistrar = $objectManager->get(ComponentRegistrarInterface::class);
|
||||
$this->schemaConfig = $objectManager->create(SchemaConfigInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that all declared table elements also declared into whitelist declaration.
|
||||
*
|
||||
* @magentoAppIsolation enabled
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testConstraintsAndIndexesAreWhitelisted()
|
||||
{
|
||||
$undeclaredElements = [];
|
||||
$resultMessage = "New table elements that do not exist in the whitelist declaration:\n";
|
||||
$whitelistTables = $this->getWhiteListTables();
|
||||
$declarativeSchema = $this->schemaConfig->getDeclarationConfig();
|
||||
|
||||
foreach ($declarativeSchema->getTables() as $schemaTable) {
|
||||
$tableNameWithoutPrefix = $schemaTable->getNameWithoutPrefix();
|
||||
foreach ($schemaTable->getConstraints() as $constraint) {
|
||||
$constraintNameWithoutPrefix = $constraint->getNameWithoutPrefix();
|
||||
if (isset($whitelistTables[$tableNameWithoutPrefix][Constraint::TYPE][$constraintNameWithoutPrefix])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$undeclaredElements[$tableNameWithoutPrefix][Constraint::TYPE][] = $constraintNameWithoutPrefix;
|
||||
}
|
||||
|
||||
foreach ($schemaTable->getIndexes() as $index) {
|
||||
$indexNameWithoutPrefix = $index->getNameWithoutPrefix();
|
||||
if (isset($whitelistTables[$tableNameWithoutPrefix][Index::TYPE][$indexNameWithoutPrefix])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$undeclaredElements[$tableNameWithoutPrefix][Index::TYPE][] = $indexNameWithoutPrefix;
|
||||
}
|
||||
}
|
||||
|
||||
$undeclaredElements = $this->filterUndeclaredElements($undeclaredElements);
|
||||
|
||||
if (!empty($undeclaredElements)) {
|
||||
$resultMessage .= json_encode($undeclaredElements, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
$this->assertEmpty($undeclaredElements, $resultMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes ignored elements from the list of undeclared table elements.
|
||||
*
|
||||
* @param array $undeclaredElements
|
||||
* @return array
|
||||
*/
|
||||
private function filterUndeclaredElements(array $undeclaredElements): array
|
||||
{
|
||||
$files = Files::getFiles([__DIR__ . '/_files/ignore_whitelisting'], '*.json');
|
||||
$ignoredElements = [];
|
||||
foreach ($files as $filePath) {
|
||||
$ignoredElements = array_merge_recursive(
|
||||
$ignoredElements,
|
||||
json_decode(file_get_contents($filePath), true)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->arrayRecursiveDiff($undeclaredElements, $ignoredElements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a recursive comparison of two arrays.
|
||||
*
|
||||
* @param array $array1
|
||||
* @param array $array2
|
||||
* @return array
|
||||
*/
|
||||
private function arrayRecursiveDiff(array $array1, array $array2): array
|
||||
{
|
||||
$diffResult = [];
|
||||
|
||||
foreach ($array1 as $key => $value) {
|
||||
if (array_key_exists($key, $array2)) {
|
||||
if (is_array($value)) {
|
||||
$recursiveDiffResult = $this->arrayRecursiveDiff($value, $array2[$key]);
|
||||
if (count($recursiveDiffResult)) {
|
||||
$diffResult[$key] = $recursiveDiffResult;
|
||||
}
|
||||
} else {
|
||||
if (!in_array($value, $array2)) {
|
||||
$diffResult[] = $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$diffResult[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $diffResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
private function getWhiteListTables(): array
|
||||
{
|
||||
$whiteListTables = [];
|
||||
|
||||
foreach ($this->componentRegistrar->getPaths(ComponentRegistrar::MODULE) as $path) {
|
||||
$whiteListPath = $path . DIRECTORY_SEPARATOR . 'etc' .
|
||||
DIRECTORY_SEPARATOR . 'db_schema_whitelist.json';
|
||||
|
||||
if (file_exists($whiteListPath)) {
|
||||
$whiteListTables = array_replace_recursive(
|
||||
$whiteListTables,
|
||||
json_decode(file_get_contents($whiteListPath), true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $whiteListTables;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"patch_list": {
|
||||
"constraint": [
|
||||
"PRIMARY"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Setup\Fixtures;
|
||||
|
||||
use Magento\Framework\Indexer\IndexerRegistry;
|
||||
use Magento\Indexer\Model\Config;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* Class Application test
|
||||
*
|
||||
* @magentoDbIsolation disabled
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class FixtureModelTest extends \Magento\TestFramework\Indexer\TestCase
|
||||
{
|
||||
/**
|
||||
* Profile generator working directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_generatorWorkingDir;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $indexersState = [];
|
||||
|
||||
/**
|
||||
* @var IndexerRegistry
|
||||
*/
|
||||
private $indexerRegistry;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $entityAsserts = [];
|
||||
|
||||
/**
|
||||
* Set indexer mode to "scheduled" for do not perform reindex after creation entity
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->indexerRegistry = $this->objectManager->get(IndexerRegistry::class);
|
||||
|
||||
$this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\SimpleProductsAssert::class);
|
||||
$this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\ConfigurableProductsAssert::class);
|
||||
$this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\BundleProductsAssert::class);
|
||||
$this->entityAsserts[] = $this->objectManager->get(FixturesAsserts\ImagesAssert::class);
|
||||
|
||||
foreach ($this->objectManager->get(Config::class)->getIndexers() as $indexerId) {
|
||||
$indexer = $this->indexerRegistry->get($indexerId['indexer_id']);
|
||||
$this->indexersState[$indexerId['indexer_id']] = $indexer->isScheduled();
|
||||
$indexer->setScheduled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return indexer to previous state
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
foreach ($this->indexersState as $indexerId => $state) {
|
||||
$indexer = $this->indexerRegistry->get($indexerId);
|
||||
$indexer->setScheduled($state);
|
||||
}
|
||||
self::restoreFromDb();
|
||||
self::$dbRestored = true;
|
||||
}
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$db = Bootstrap::getInstance()->getBootstrap()
|
||||
->getApplication()
|
||||
->getDbInstance();
|
||||
if (!$db->isDbDumpExists()) {
|
||||
throw new \LogicException('DB dump does not exist.');
|
||||
}
|
||||
$db->restoreFromDbDump();
|
||||
|
||||
self::$_generatorWorkingDir = realpath(
|
||||
__DIR__ . '/../../../../../../../setup/src/Magento/Setup/Fixtures/_files'
|
||||
);
|
||||
copy(
|
||||
self::$_generatorWorkingDir . '/tax_rates.csv',
|
||||
self::$_generatorWorkingDir . '/tax_rates.csv.bak'
|
||||
);
|
||||
copy(
|
||||
__DIR__ . '/_files/tax_rates.csv',
|
||||
self::$_generatorWorkingDir . '/tax_rates.csv'
|
||||
);
|
||||
parent::setUpBeforeClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate test profile and performs assertions that generated entities are valid
|
||||
*/
|
||||
public function testFixtureGeneration()
|
||||
{
|
||||
$reindexCommand = Bootstrap::getObjectManager()->get(
|
||||
\Magento\Indexer\Console\Command\IndexerReindexCommand::class
|
||||
);
|
||||
$itfApplication = Bootstrap::getInstance()->getBootstrap()->getApplication();
|
||||
$model = new FixtureModel($reindexCommand, $itfApplication->getInitParams());
|
||||
$model->loadConfig(__DIR__ . '/_files/small.xml');
|
||||
$model->initObjectManager();
|
||||
|
||||
foreach ($model->loadFixtures()->getFixtures() as $fixture) {
|
||||
$fixture->execute();
|
||||
}
|
||||
|
||||
foreach ($this->entityAsserts as $entityAssert) {
|
||||
try {
|
||||
$this->assertTrue($entityAssert->assert());
|
||||
} catch (\AssertionError $assertionError) {
|
||||
$this->assertTrue(false, $assertionError->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
parent::tearDownAfterClass();
|
||||
|
||||
unlink(self::$_generatorWorkingDir . '/tax_rates.csv');
|
||||
rename(
|
||||
self::$_generatorWorkingDir . '/tax_rates.csv.bak',
|
||||
self::$_generatorWorkingDir . '/tax_rates.csv'
|
||||
);
|
||||
/** @var $appCache \Magento\Framework\App\Cache */
|
||||
$appCache = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Cache::class);
|
||||
$appCache->clean(
|
||||
[
|
||||
\Magento\Eav\Model\Cache\Type::CACHE_TAG,
|
||||
\Magento\Eav\Model\Entity\Attribute::CACHE_TAG,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Fixtures\FixturesAsserts;
|
||||
|
||||
use Magento\Setup\Fixtures\BundleProductsFixture;
|
||||
|
||||
/**
|
||||
* Class BundleProductsAssert
|
||||
*
|
||||
* Class performs assertion that generated bundle products are valid
|
||||
* after running setup:performance:generate-fixtures command
|
||||
*/
|
||||
class BundleProductsAssert
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Catalog\Api\ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\Bundle\Model\Product\OptionList
|
||||
*/
|
||||
private $optionList;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert
|
||||
*/
|
||||
private $productAssert;
|
||||
|
||||
/**
|
||||
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
|
||||
* @param \Magento\Bundle\Model\Product\OptionList $optionList
|
||||
* @param \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
|
||||
\Magento\Bundle\Model\Product\OptionList $optionList,
|
||||
\Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
) {
|
||||
$this->productRepository = $productRepository;
|
||||
$this->optionList = $optionList;
|
||||
$this->productAssert = $productAssert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that generated bundled products are valid
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assert()
|
||||
{
|
||||
$bundleSkuSuffix = '2-2';
|
||||
$product = $this->productRepository->get(
|
||||
sprintf(BundleProductsFixture::SKU_PATTERN, 1, $bundleSkuSuffix)
|
||||
);
|
||||
|
||||
$this->productAssert->assertProductsCount(
|
||||
sprintf(BundleProductsFixture::SKU_PATTERN, '%s', $bundleSkuSuffix),
|
||||
2
|
||||
);
|
||||
$this->productAssert->assertProductType('bundle', $product);
|
||||
|
||||
if (2 !== count($this->optionList->getItems($product))) {
|
||||
throw new \AssertionError('Bundle options amount is wrong');
|
||||
}
|
||||
|
||||
foreach ($this->optionList->getItems($product) as $option) {
|
||||
if (2 !== count($option->getProductLinks())) {
|
||||
throw new \AssertionError('Bundle option product links amount is wrong');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Fixtures\FixturesAsserts;
|
||||
|
||||
/**
|
||||
* Class ConfigurableProductsAssert
|
||||
*
|
||||
* Class performs assertion that generated configurable products are valid
|
||||
* after running setup:performance:generate-fixtures command
|
||||
*/
|
||||
class ConfigurableProductsAssert
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Catalog\Api\ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\ConfigurableProduct\Api\OptionRepositoryInterface
|
||||
*/
|
||||
private $optionRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert
|
||||
*/
|
||||
private $productAssert;
|
||||
|
||||
/**
|
||||
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
|
||||
* @param \Magento\ConfigurableProduct\Api\OptionRepositoryInterface $optionRepository
|
||||
* @param \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
|
||||
\Magento\ConfigurableProduct\Api\OptionRepositoryInterface $optionRepository,
|
||||
\Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
) {
|
||||
$this->productRepository = $productRepository;
|
||||
$this->optionRepository = $optionRepository;
|
||||
$this->productAssert = $productAssert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that generated configurable products are valid
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \Magento\Framework\Exception\InputException
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assert()
|
||||
{
|
||||
$productsMap = [
|
||||
'Configurable Product - Default %s' => [
|
||||
'attributes' => 1,
|
||||
'options' => 3,
|
||||
'amount' => 2,
|
||||
],
|
||||
'Configurable Product - Color-Size %s' => [
|
||||
'attributes' => 2,
|
||||
'options' => 3,
|
||||
'amount' => 2,
|
||||
],
|
||||
'Configurable Product 2-2 %s' => [
|
||||
'attributes' => 2,
|
||||
'options' => 2,
|
||||
'amount' => 2,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($productsMap as $skuPattern => $expectedData) {
|
||||
$configurableSku = sprintf($skuPattern, 1);
|
||||
$product = $this->productRepository->get($configurableSku);
|
||||
$this->productAssert->assertProductsCount($skuPattern, $expectedData['amount']);
|
||||
$this->productAssert->assertProductType('configurable', $product);
|
||||
$options = $this->optionRepository->getList($configurableSku);
|
||||
|
||||
if ($expectedData['attributes'] !== count($options)) {
|
||||
throw new \AssertionError('Configurable options amount is wrong');
|
||||
}
|
||||
|
||||
if ($expectedData['options'] !== count($options[0]->getValues())) {
|
||||
throw new \AssertionError('Configurable option values amount is wrong');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Setup\Fixtures\FixturesAsserts;
|
||||
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
|
||||
/**
|
||||
* Class ImagesAssert
|
||||
*
|
||||
* Class performs assertions to check that generated images are valid
|
||||
* after running setup:performance:generate-fixtures command
|
||||
*/
|
||||
class ImagesAssert
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Catalog\Api\ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Api\SearchCriteriaBuilder
|
||||
*/
|
||||
private $searchCriteriaBuilder;
|
||||
|
||||
/**
|
||||
* @var \Magento\Catalog\Model\Product\Gallery\ReadHandler
|
||||
*/
|
||||
private $readHandler;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Filesystem
|
||||
*/
|
||||
private $filesystem;
|
||||
|
||||
/**
|
||||
* @var \Magento\Catalog\Model\Product\Media\Config
|
||||
*/
|
||||
private $mediaConfig;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\Filesystem\Directory\ReadInterface
|
||||
*/
|
||||
private $mediaDirectory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder
|
||||
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
|
||||
* @param \Magento\Catalog\Model\Product\Gallery\ReadHandler $readHandler
|
||||
* @param \Magento\Framework\Filesystem $filesystem
|
||||
* @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
|
||||
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
|
||||
\Magento\Catalog\Model\Product\Gallery\ReadHandler $readHandler,
|
||||
\Magento\Framework\Filesystem $filesystem,
|
||||
\Magento\Catalog\Model\Product\Media\Config $mediaConfig
|
||||
) {
|
||||
$this->productRepository = $productRepository;
|
||||
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
|
||||
$this->readHandler = $readHandler;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->mediaConfig = $mediaConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertions over images
|
||||
*
|
||||
* @return bool
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assert()
|
||||
{
|
||||
$searchCriteria = $this->searchCriteriaBuilder->create();
|
||||
$products = $this->productRepository->getList($searchCriteria)->getItems();
|
||||
|
||||
foreach ($products as $product) {
|
||||
$this->assertProductMediaGallery($product);
|
||||
$this->assertProductMediaAttributes($product);
|
||||
$this->assertProductImageExistsInFS($product);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertions over media_gallery product attribute
|
||||
*
|
||||
* @param \Magento\Catalog\Model\Product $product
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
private function assertProductMediaGallery(\Magento\Catalog\Model\Product $product)
|
||||
{
|
||||
$extendedProduct = $this->readHandler->execute($product);
|
||||
$mediaGalleryImages = $extendedProduct->getMediaGalleryEntries();
|
||||
|
||||
if (count($mediaGalleryImages) !== 1) {
|
||||
throw new \AssertionError('Product supposed to contain one image');
|
||||
}
|
||||
|
||||
$image = reset($mediaGalleryImages);
|
||||
|
||||
if ($image->getFile() === null) {
|
||||
throw new \AssertionError('Image path should not be null');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertions over product media attributes
|
||||
* e.g. image|small_image|swatch_image|thumbnail
|
||||
*
|
||||
* @param \Magento\Catalog\Model\Product $product
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
private function assertProductMediaAttributes(\Magento\Catalog\Model\Product $product)
|
||||
{
|
||||
foreach ($product->getMediaAttributeValues() as $attributeCode => $attributeValue) {
|
||||
if (empty($attributeValue)) {
|
||||
throw new \AssertionError(
|
||||
sprintf('Attribute: %s should not be empty', $attributeCode)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertions over image files in FS
|
||||
*
|
||||
* @param \Magento\Catalog\Model\Product $product
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
private function assertProductImageExistsInFS(\Magento\Catalog\Model\Product $product)
|
||||
{
|
||||
$mediaDirectory = $this->getMediaDirectory();
|
||||
$mediaAttributes = $product->getMediaAttributeValues();
|
||||
|
||||
if (!$mediaDirectory->isExist($this->mediaConfig->getBaseMediaPath() . $mediaAttributes['image'])) {
|
||||
throw new \AssertionError('Image file for product supposed to exist');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Local cache for $mediaDirectory
|
||||
*
|
||||
* @return \Magento\Framework\Filesystem\Directory\ReadInterface
|
||||
*/
|
||||
private function getMediaDirectory()
|
||||
{
|
||||
if ($this->mediaDirectory === null) {
|
||||
$this->mediaDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
|
||||
}
|
||||
|
||||
return $this->mediaDirectory;
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Fixtures\FixturesAsserts;
|
||||
|
||||
/**
|
||||
* Class ProductAssert
|
||||
*
|
||||
* Class provides assertions about products count and products type
|
||||
* that helps validate them after running setup:performance:generate-fixtures command
|
||||
*/
|
||||
class ProductAssert
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Catalog\Model\ResourceModel\Product\
|
||||
*/
|
||||
protected $productCollectionFactory;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\DB\Sql\ColumnValueExpressionFactory
|
||||
*/
|
||||
protected $expressionFactory;
|
||||
|
||||
/**
|
||||
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
|
||||
* @param \Magento\Framework\DB\Sql\ColumnValueExpressionFactory $expressionFactory
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
|
||||
\Magento\Framework\DB\Sql\ColumnValueExpressionFactory $expressionFactory
|
||||
) {
|
||||
$this->productCollectionFactory = $productCollectionFactory;
|
||||
$this->expressionFactory = $expressionFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertion on generated products count
|
||||
* Accepts products sku pattern to calculate count and theirs expected count
|
||||
*
|
||||
* @param string $skuPattern
|
||||
* @param int $expectedCount
|
||||
* @return void
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assertProductsCount($skuPattern, $expectedCount)
|
||||
{
|
||||
$productSkuPattern = str_replace('%s', '[0-9]+', $skuPattern);
|
||||
$productCollection = $this->productCollectionFactory->create();
|
||||
$productCollection
|
||||
->getSelect()
|
||||
->where('sku ?', $this->expressionFactory->create([
|
||||
'expression' => 'REGEXP \'^' . $productSkuPattern . '$\''
|
||||
]));
|
||||
|
||||
if ($expectedCount !== count($productCollection)) {
|
||||
throw new \AssertionError(
|
||||
sprintf(
|
||||
'Expected amount of products with sku pattern "%s" not equals actual amount',
|
||||
$skuPattern
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs assertion that product has expected product type
|
||||
*
|
||||
* @param string $expectedProductType
|
||||
* @param \Magento\Catalog\Api\Data\ProductInterface $product
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assertProductType($expectedProductType, $product)
|
||||
{
|
||||
if ($expectedProductType !== $product->getTypeId()) {
|
||||
throw new \AssertionError('Product type is wrong');
|
||||
}
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Fixtures\FixturesAsserts;
|
||||
|
||||
use Magento\Setup\Fixtures\SimpleProductsFixture;
|
||||
|
||||
/**
|
||||
* Class SimpleProductsAssert
|
||||
*
|
||||
* Class performs assertion that generated simple products are valid
|
||||
* after running setup:performance:generate-fixtures command
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class SimpleProductsAssert
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Catalog\Api\ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert
|
||||
*/
|
||||
private $productAssert;
|
||||
|
||||
/**
|
||||
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
|
||||
* @param \Magento\ConfigurableProduct\Api\OptionRepositoryInterface $optionRepository
|
||||
* @param \Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
*/
|
||||
public function __construct(
|
||||
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
|
||||
\Magento\ConfigurableProduct\Api\OptionRepositoryInterface $optionRepository,
|
||||
\Magento\Setup\Fixtures\FixturesAsserts\ProductAssert $productAssert
|
||||
) {
|
||||
$this->productRepository = $productRepository;
|
||||
$this->optionRepository = $optionRepository;
|
||||
$this->productAssert = $productAssert;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that generated simple products are valid
|
||||
*
|
||||
* @return bool
|
||||
* @throws \Magento\Framework\Exception\NoSuchEntityException
|
||||
* @throws \AssertionError
|
||||
*/
|
||||
public function assert()
|
||||
{
|
||||
$product = $this->productRepository->get(sprintf(SimpleProductsFixture::SKU_PATTERN, 1));
|
||||
$this->productAssert->assertProductsCount(SimpleProductsFixture::SKU_PATTERN, 2);
|
||||
$this->productAssert->assertProductType('simple', $product);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<attribute_sets> <!-- Content of Attribute Sets -->
|
||||
<attribute_set>
|
||||
<name>Attribute Set 1</name>
|
||||
<attributes>
|
||||
<attribute>
|
||||
<is_required>1</is_required>
|
||||
<is_visible_on_front>1</is_visible_on_front>
|
||||
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
|
||||
<attribute_code>mycolor</attribute_code>
|
||||
<backend_type></backend_type>
|
||||
<is_searchable>1</is_searchable>
|
||||
<is_filterable>1</is_filterable>
|
||||
<is_filterable_in_search>1</is_filterable_in_search>
|
||||
<frontend_label>my color</frontend_label>
|
||||
<frontend_input>select</frontend_input>
|
||||
<default_value>my yellow</default_value>
|
||||
<options>
|
||||
<option>
|
||||
<label>my green</label>
|
||||
<value>my green</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>my red</label>
|
||||
<value>my red</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>my yellow</label>
|
||||
<value>my yellow</value>
|
||||
</option>
|
||||
</options>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<is_required>1</is_required>
|
||||
<is_visible_on_front>1</is_visible_on_front>
|
||||
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
|
||||
<attribute_code>mysize</attribute_code>
|
||||
<backend_type></backend_type>
|
||||
<is_searchable>1</is_searchable>
|
||||
<is_filterable>1</is_filterable>
|
||||
<is_filterable_in_search>1</is_filterable_in_search>
|
||||
<frontend_label>my size</frontend_label>
|
||||
<frontend_input>select</frontend_input>
|
||||
<default_value>my large</default_value>
|
||||
<options>
|
||||
<option>
|
||||
<label>my small</label>
|
||||
<value>my small</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>my medium</label>
|
||||
<value>my medium</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>my large</label>
|
||||
<value>my large</value>
|
||||
</option>
|
||||
</options>
|
||||
</attribute>
|
||||
</attributes>
|
||||
</attribute_set>
|
||||
<attribute_set>
|
||||
<name>Attribute Set 2</name>
|
||||
<attributes>
|
||||
<attribute>
|
||||
<is_required>1</is_required>
|
||||
<is_visible_on_front>1</is_visible_on_front>
|
||||
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
|
||||
<attribute_code>attributeset2attribute1</attribute_code>
|
||||
<backend_type></backend_type>
|
||||
<is_searchable>1</is_searchable>
|
||||
<is_filterable>1</is_filterable>
|
||||
<is_filterable_in_search>1</is_filterable_in_search>
|
||||
<frontend_label>Attribute Set 2 - Attribute 1</frontend_label>
|
||||
<frontend_input>select</frontend_input>
|
||||
<default_value>attributeset2attribute1option1</default_value>
|
||||
<options>
|
||||
<option>
|
||||
<label>Attribute Set 2 - Attribute 1 - Option a</label>
|
||||
<value>attributeset2attribute1option1</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>Attribute Set 2 - Attribute 1 - Option b</label>
|
||||
<value>attributeset2attribute1option2</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>Attribute Set 2 - Attribute 1 - Option c</label>
|
||||
<value>attributeset2attribute1option3</value>
|
||||
</option>
|
||||
</options>
|
||||
</attribute>
|
||||
</attributes>
|
||||
</attribute_set>
|
||||
<attribute_set>
|
||||
<name>Attribute Set 3</name>
|
||||
<attributes>
|
||||
<attribute>
|
||||
<is_required>1</is_required>
|
||||
<is_visible_on_front>1</is_visible_on_front>
|
||||
<is_visible_in_advanced_search>1</is_visible_in_advanced_search>
|
||||
<attribute_code>attributeset3attribute1</attribute_code>
|
||||
<backend_type></backend_type>
|
||||
<is_searchable>1</is_searchable>
|
||||
<is_filterable>1</is_filterable>
|
||||
<is_filterable_in_search>1</is_filterable_in_search>
|
||||
<frontend_label>Attribute Set 3 - Attribute 1</frontend_label>
|
||||
<frontend_input>select</frontend_input>
|
||||
<default_value>attributeset3attribute1option1</default_value>
|
||||
<options>
|
||||
<option>
|
||||
<label>Attribute Set 3 - Attribute 1 - Option a</label>
|
||||
<value>attributeset3attribute1option1</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>Attribute Set 3 - Attribute 1 - Option b</label>
|
||||
<value>attributeset3attribute1option2</value>
|
||||
</option>
|
||||
<option>
|
||||
<label>Attribute Set 3 - Attribute 1 - Option c</label>
|
||||
<value>attributeset3attribute1option3</value>
|
||||
</option>
|
||||
</options>
|
||||
</attribute>
|
||||
</attributes>
|
||||
</attribute_set>
|
||||
</attribute_sets>
|
||||
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<profile>
|
||||
<di>di.xml</di>
|
||||
<websites>1</websites>
|
||||
<store_groups>1</store_groups>
|
||||
<store_views>1</store_views>
|
||||
<simple_products>2</simple_products>
|
||||
<bundle_products>2</bundle_products>
|
||||
<bundle_products_options>2</bundle_products_options>
|
||||
<bundle_products_variation>2</bundle_products_variation>
|
||||
<product-images>
|
||||
<images-count>3</images-count>
|
||||
<images-per-product>1</images-per-product>
|
||||
</product-images>
|
||||
<configurable_products>
|
||||
<config>
|
||||
<attributeSet>Default</attributeSet>
|
||||
<sku>Configurable Product - Default %s</sku>
|
||||
<products>2</products>
|
||||
</config>
|
||||
<config>
|
||||
<attributeSet>Attribute Set 1</attributeSet>
|
||||
<sku>Configurable Product - Color-Size %s</sku>
|
||||
<products>2</products>
|
||||
</config>
|
||||
<config>
|
||||
<attributes>2</attributes>
|
||||
<options>2</options>
|
||||
<sku>Configurable Product 2-2 %s</sku>
|
||||
<products>2</products>
|
||||
</config>
|
||||
</configurable_products>
|
||||
<configurable_products_variation>3</configurable_products_variation>
|
||||
<categories>30</categories>
|
||||
<categories_nesting_level>3</categories_nesting_level>
|
||||
<catalog_price_rules>10</catalog_price_rules>
|
||||
<configs> <!-- Config variables and values for change -->
|
||||
<config>
|
||||
<path>admin/security/use_form_key</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>0</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>carriers/flatrate/active</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>1</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>system/full_page_cache/ttl</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>7200</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>system/full_page_cache/caching_application</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>2</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>checkout/cart/redirect_to_cart</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>0</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>system/full_page_cache/varnish/access_list</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>localhost</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>system/full_page_cache/varnish/backend_host</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>localhost</value>
|
||||
</config>
|
||||
<config>
|
||||
<path>system/full_page_cache/varnish/backend_port</path>
|
||||
<scope>default</scope>
|
||||
<scopeId>0</scopeId>
|
||||
<value>8080</value>
|
||||
</config>
|
||||
</configs>
|
||||
<indexers> <!-- Indexer mode value (true - Update by Schedule, false - Update on Save) -->
|
||||
<indexer>
|
||||
<id>catalog_category_product</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_category</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_price</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalog_product_attribute</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>cataloginventory_stock</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogrule_rule</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogrule_product</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
<indexer>
|
||||
<id>catalogsearch_fulltext</id>
|
||||
<set_scheduled>false</set_scheduled>
|
||||
</indexer>
|
||||
</indexers>
|
||||
<xi:include href="./attributeSets.xml"/>
|
||||
</profile>
|
||||
</config>
|
||||
@@ -0,0 +1,20 @@
|
||||
Code,Country,State,"Zip/Post Code",Rate,"Zip/Post is Range","Range From","Range To",default
|
||||
US-AK-99547,US,AK,99547,3,,,,
|
||||
US-AK-99554,US,AK,99554,4,,,,
|
||||
US-AK-99555,US,AK,99555,5,,,,
|
||||
US-AK-99556,US,AK,99556,3,,,,
|
||||
US-AK-99557,US,AK,99557,2,,,,
|
||||
US-AK-99559,US,AK,99559,6,,,,
|
||||
US-AK-99561,US,AK,99561,2,,,,
|
||||
US-AK-99563,US,AK,99563,3,,,,
|
||||
US-AK-99568,US,AK,99568,3,,,,
|
||||
US-AK-99569,US,AK,99569,5,,,,
|
||||
US-AK-99572,US,AK,99572,3,,,,
|
||||
US-AK-99574,US,AK,99574,6,,,,
|
||||
US-AK-99576,US,AK,99576,6,,,,
|
||||
US-AK-99578,US,AK,99578,2,,,,
|
||||
US-AK-99581,US,AK,99581,3,,,,
|
||||
US-AK-99583,US,AK,99583,3,,,,
|
||||
US-AK-99585,US,AK,99585,4,,,,
|
||||
US-AK-99591,US,AK,99591,3,,,,
|
||||
US-AK-99603,US,AK,99603,7.5,,,,
|
||||
|
+74
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Model;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrarInterface;
|
||||
use Magento\Setup\Validator\DbValidator;
|
||||
use Laminas\ServiceManager\ServiceLocatorInterface;
|
||||
|
||||
class ConfigOptionsListCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $objectManagerProvider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManagerProvider = $this->createMock(ObjectManagerProvider::class);
|
||||
$this->objectManagerProvider
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->willReturn(\Magento\TestFramework\Helper\Bootstrap::getObjectManager());
|
||||
}
|
||||
|
||||
public function testCollectOptionsLists()
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$componentRegistrar = $this->createMock(ComponentRegistrarInterface::class);
|
||||
$componentRegistrar->expects($this->once())
|
||||
->method('getPaths')
|
||||
->willReturn(['Magento_Backend'=>'app/code/Magento/Backend']);
|
||||
|
||||
$dbValidator = $this->createMock(DbValidator::class);
|
||||
$configGenerator = $this->createMock(ConfigGenerator::class);
|
||||
|
||||
$setupOptions = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
|
||||
->create(
|
||||
\Magento\Setup\Model\ConfigOptionsList::class,
|
||||
[
|
||||
'configGenerator' => $configGenerator,
|
||||
'dbValidator' => $dbValidator
|
||||
]
|
||||
);
|
||||
|
||||
$serviceLocator = $this->getMockForAbstractClass(ServiceLocatorInterface::class);
|
||||
|
||||
$serviceLocator->expects($this->once())
|
||||
->method('get')
|
||||
->with(\Magento\Setup\Model\ConfigOptionsList::class)
|
||||
->willReturn($setupOptions);
|
||||
|
||||
/** @var \Magento\Setup\Model\ConfigOptionsListCollector $object */
|
||||
$object = $objectManager->create(
|
||||
\Magento\Setup\Model\ConfigOptionsListCollector::class,
|
||||
[
|
||||
'objectManagerProvider' => $this->objectManagerProvider,
|
||||
'componentRegistrar' => $componentRegistrar,
|
||||
'serviceLocator' => $serviceLocator
|
||||
]
|
||||
);
|
||||
$result = $object->collectOptionsLists();
|
||||
|
||||
$backendOptions = new \Magento\Backend\Setup\ConfigOptionsList();
|
||||
$expected = [
|
||||
'setup' => $setupOptions,
|
||||
'Magento_Backend' => $backendOptions,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Setup\Model\FixtureGenerator;
|
||||
|
||||
use Magento\Catalog\Api\ProductRepositoryInterface;
|
||||
use Magento\Framework\Indexer\IndexerRegistry;
|
||||
use Magento\Indexer\Model\Config;
|
||||
use Magento\Store\Model\WebsiteRepository;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @magentoAppArea adminhtml
|
||||
* @magentoDataFixture Magento/Catalog/_files/category.php
|
||||
* @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
|
||||
*/
|
||||
class ProductGeneratorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ProductGenerator
|
||||
*/
|
||||
private $productGenerator;
|
||||
|
||||
/**
|
||||
* @var \Magento\Framework\ObjectManagerInterface
|
||||
*/
|
||||
private $objectManager;
|
||||
|
||||
/**
|
||||
* @var \Magento\Catalog\Api\ProductRepositoryInterface
|
||||
*/
|
||||
private $productRepository;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $indexersState = [];
|
||||
|
||||
/**
|
||||
* @var WebsiteRepository
|
||||
*/
|
||||
private $websiteRepository;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
|
||||
$this->productGenerator = $this->objectManager->get(ProductGenerator::class);
|
||||
$this->websiteRepository = $this->objectManager->get(WebsiteRepository::class);
|
||||
$indexerRegistry = $this->objectManager->get(IndexerRegistry::class);
|
||||
$indexerListIds = $this->objectManager->get(Config::class)->getIndexers();
|
||||
|
||||
foreach ($indexerListIds as $indexerId) {
|
||||
$indexer = $indexerRegistry->get($indexerId['indexer_id']);
|
||||
$this->indexersState[$indexerId['indexer_id']] = $indexer->isScheduled();
|
||||
$indexer->setScheduled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return indexer to previous state
|
||||
*/
|
||||
protected function tearDown(): void
|
||||
{
|
||||
$indexerRegistry = $this->objectManager->get(IndexerRegistry::class);
|
||||
|
||||
foreach ($this->indexersState as $indexerId => $state) {
|
||||
$indexer = $indexerRegistry->get($indexerId);
|
||||
$indexer->setScheduled($state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDbIsolation disabled
|
||||
*/
|
||||
public function testProductGeneration()
|
||||
{
|
||||
$name = 'Simple Product Name';
|
||||
$sku = 'simple_product_sku';
|
||||
$price = 7.99;
|
||||
$url = 'simple-product-url';
|
||||
$categoryId = 333;
|
||||
$secondWebsiteId = $this->websiteRepository->get('test')->getId();
|
||||
|
||||
$fixtureMap = [
|
||||
'name' => function () use ($name) {
|
||||
return $name;
|
||||
},
|
||||
'sku' => function () use ($sku) {
|
||||
return $sku;
|
||||
},
|
||||
'price' => function () use ($price) {
|
||||
return $price;
|
||||
},
|
||||
'url_key' => function () use ($url) {
|
||||
return $url;
|
||||
},
|
||||
'category_ids' => function () use ($categoryId) {
|
||||
return $categoryId;
|
||||
},
|
||||
'website_ids' => function () use ($secondWebsiteId) {
|
||||
return [1, $secondWebsiteId];
|
||||
}
|
||||
];
|
||||
$this->productGenerator->generate(1, $fixtureMap);
|
||||
|
||||
$product = $this->productRepository->get($sku);
|
||||
|
||||
$this->assertEquals($price, $product->getPrice());
|
||||
$this->assertEquals($name, $product->getName());
|
||||
$this->assertEquals($url, $product->getUrlKey());
|
||||
$this->assertTrue(in_array($categoryId, $product->getCategoryIds()));
|
||||
|
||||
$this->productRepository->delete($product);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
namespace Magento\Setup\Model;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Laminas\ServiceManager\ServiceLocatorInterface;
|
||||
|
||||
/**
|
||||
* Tests ObjectManagerProvider
|
||||
*/
|
||||
class ObjectManagerProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var ObjectManagerProvider
|
||||
*/
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* @var ServiceLocatorInterface|PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $locator;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->locator = $this->getMockForAbstractClass(ServiceLocatorInterface::class);
|
||||
$this->object = new ObjectManagerProvider($this->locator, new Bootstrap());
|
||||
$this->locator->expects($this->any())
|
||||
->method('get')
|
||||
->willReturnMap(
|
||||
[
|
||||
[InitParamListener::BOOTSTRAP_PARAM, []],
|
||||
[Application::class, $this->getMockForAbstractClass(Application::class)],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the same instance of ObjectManagerInterface should be provided by the ObjectManagerProvider
|
||||
*/
|
||||
public function testGet()
|
||||
{
|
||||
$objectManager = $this->object->get();
|
||||
$this->assertInstanceOf(ObjectManagerInterface::class, $objectManager);
|
||||
$this->assertSame($objectManager, $this->object->get());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"magento/product-community-edition": "*",
|
||||
"magento/sample-module-minimal" : "*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Magento\\Framework\\": "htdocs/lib/internal/Magento/Framework/",
|
||||
"Magento\\Setup\\": "htdocs/setup/src/Magento/Setup/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"magento-root-dir": "htdocs",
|
||||
"magento-deploystrategy": "copy"
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
+6022
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module;
|
||||
|
||||
use Magento\Framework\Setup\ModuleDataSetupInterface;
|
||||
|
||||
class DataSetupTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var ModuleDataSetupInterface
|
||||
*/
|
||||
protected $_model;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Setup\Module\DataSetup::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testUpdateTableRow()
|
||||
{
|
||||
$original = $this->_model->getTableRow('setup_module', 'module', 'Magento_AdminNotification', 'schema_version');
|
||||
$this->_model->updateTableRow('setup_module', 'module', 'Magento_AdminNotification', 'schema_version', 'test');
|
||||
$this->assertEquals(
|
||||
'test',
|
||||
$this->_model->getTableRow('setup_module', 'module', 'Magento_AdminNotification', 'schema_version')
|
||||
);
|
||||
$this->_model->updateTableRow(
|
||||
'setup_module',
|
||||
'module',
|
||||
'Magento_AdminNotification',
|
||||
'schema_version',
|
||||
$original
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeleteTableRow()
|
||||
{
|
||||
$this->expectException(\Magento\Framework\DB\Adapter\TableNotFoundException::class);
|
||||
|
||||
$this->_model->deleteTableRow('setup/module', 'module', 'integration_test_fixture_setup');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\DataSetup::updateTableRow
|
||||
*/
|
||||
public function testUpdateTableRowNameConversion()
|
||||
{
|
||||
$this->expectException(\Magento\Framework\DB\Adapter\TableNotFoundException::class);
|
||||
|
||||
$original = $this->_model->getTableRow('setup_module', 'module', 'core_setup', 'schema_version');
|
||||
$this->_model->updateTableRow('setup/module', 'module', 'core_setup', 'schema_version', $original);
|
||||
}
|
||||
|
||||
public function testTableExists()
|
||||
{
|
||||
$this->assertTrue($this->_model->tableExists('store_website'));
|
||||
$this->assertFalse($this->_model->tableExists('core/website'));
|
||||
}
|
||||
|
||||
public function testGetSetupCache()
|
||||
{
|
||||
$this->assertInstanceOf(\Magento\Framework\Setup\DataCacheInterface::class, $this->_model->getSetupCache());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency;
|
||||
|
||||
class CircularTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var Circular
|
||||
*/
|
||||
protected $circular;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->circular = new Circular();
|
||||
}
|
||||
|
||||
public function testBuildCircularDependencies()
|
||||
{
|
||||
$dependencies = [1 => [2], 2 => [3, 5], 3 => [1], 5 => [2]];
|
||||
$expectedCircularDependencies = [
|
||||
1 => [[1, 2, 3, 1]],
|
||||
2 => [[2, 3, 1, 2], [2, 5, 2]],
|
||||
3 => [[3, 1, 2, 3]],
|
||||
5 => [[5, 2, 5]],
|
||||
];
|
||||
$this->assertEquals($expectedCircularDependencies, $this->circular->buildCircularDependencies($dependencies));
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency\Parser\Composer;
|
||||
|
||||
class JsonTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDir;
|
||||
|
||||
/**
|
||||
* @var Json
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixtureDir = realpath(__DIR__ . '/../../_files') . '/';
|
||||
|
||||
$this->parser = new Json();
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$expected = [
|
||||
[
|
||||
'name' => 'magento/module-module1',
|
||||
'dependencies' => [
|
||||
['module' => 'magento/module-module2', 'type' => 'hard'],
|
||||
['module' => 'magento/module-backend', 'type' => 'soft'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'magento/module-module2',
|
||||
'dependencies' => [
|
||||
['module' => 'magento/module-module3', 'type' => 'hard'],
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
$actual = $this->parser->parse(
|
||||
[
|
||||
'files_for_parse' => [
|
||||
$this->fixtureDir . 'composer1.json',
|
||||
$this->fixtureDir . 'composer2.json',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency\Parser\Config;
|
||||
|
||||
class XmlTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDir;
|
||||
|
||||
/**
|
||||
* @var Xml
|
||||
*/
|
||||
protected $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixtureDir = realpath(__DIR__ . '/../../_files') . '/';
|
||||
|
||||
$this->parser = new Xml();
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$expected = [
|
||||
'Magento\Module1',
|
||||
'Magento\Module2',
|
||||
];
|
||||
|
||||
$actual = $this->parser->parse(
|
||||
['files_for_parse' => [$this->fixtureDir . 'module1.xml', $this->fixtureDir . 'module2.xml']]
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency\Report;
|
||||
|
||||
use Magento\Setup\Module\Dependency\ServiceLocator;
|
||||
|
||||
class CircularTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sourceFilename;
|
||||
|
||||
/**
|
||||
* @var BuilderInterface
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixtureDir = realpath(__DIR__ . '/../_files') . '/';
|
||||
$this->sourceFilename = $this->fixtureDir . 'circular-dependencies.csv';
|
||||
|
||||
$this->builder = ServiceLocator::getCircularDependenciesReportBuilder();
|
||||
}
|
||||
|
||||
public function testBuild()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => [
|
||||
'files_for_parse' => [$this->fixtureDir . 'composer4.json', $this->fixtureDir . 'composer5.json'],
|
||||
],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals($this->fixtureDir . 'expected/circular-dependencies.csv', $this->sourceFilename);
|
||||
}
|
||||
|
||||
public function testBuildWithoutDependencies()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => ['files_for_parse' => [$this->fixtureDir . 'composer3.json']],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals(
|
||||
$this->fixtureDir . 'expected/without-circular-dependencies.csv',
|
||||
$this->sourceFilename
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists($this->sourceFilename)) {
|
||||
unlink($this->sourceFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency\Report;
|
||||
|
||||
use Magento\Setup\Module\Dependency\ServiceLocator;
|
||||
|
||||
class DependencyTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sourceFilename;
|
||||
|
||||
/**
|
||||
* @var BuilderInterface
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixtureDir = realpath(__DIR__ . '/../_files') . '/';
|
||||
$this->sourceFilename = $this->fixtureDir . 'dependencies.csv';
|
||||
|
||||
$this->builder = ServiceLocator::getDependenciesReportBuilder();
|
||||
}
|
||||
|
||||
public function testBuild()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => [
|
||||
'files_for_parse' => [$this->fixtureDir . 'composer1.json', $this->fixtureDir . 'composer2.json'],
|
||||
],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals($this->fixtureDir . 'expected/dependencies.csv', $this->sourceFilename);
|
||||
}
|
||||
|
||||
public function testBuildWithoutDependencies()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => ['files_for_parse' => [$this->fixtureDir . 'composer3.json']],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals($this->fixtureDir . 'expected/without-dependencies.csv', $this->sourceFilename);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists($this->sourceFilename)) {
|
||||
unlink($this->sourceFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\Dependency\Report;
|
||||
|
||||
use Magento\Setup\Module\Dependency\ServiceLocator;
|
||||
|
||||
class FrameworkTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $fixtureDirModule;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $sourceFilename;
|
||||
|
||||
/**
|
||||
* @var BuilderInterface
|
||||
*/
|
||||
protected $builder;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->fixtureDir = realpath(__DIR__ . '/../_files') . '/';
|
||||
$this->fixtureDirModule = $this->fixtureDir . 'code/Magento/FirstModule/';
|
||||
$this->sourceFilename = $this->fixtureDir . 'framework-dependencies.csv';
|
||||
|
||||
$this->builder = ServiceLocator::getFrameworkDependenciesReportBuilder();
|
||||
}
|
||||
|
||||
public function testBuild()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => [
|
||||
'files_for_parse' => [
|
||||
$this->fixtureDirModule . 'Helper/Helper.php',
|
||||
$this->fixtureDirModule . 'Model/Model.php',
|
||||
$this->fixtureDirModule . 'view/frontend/template.phtml',
|
||||
],
|
||||
'config_files' => [$this->fixtureDirModule . 'etc/module.xml'],
|
||||
'declared_namespaces' => ['Magento'],
|
||||
],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals($this->fixtureDir . 'expected/framework-dependencies.csv', $this->sourceFilename);
|
||||
}
|
||||
|
||||
public function testBuildWithoutDependencies()
|
||||
{
|
||||
$this->builder->build(
|
||||
[
|
||||
'parse' => [
|
||||
'files_for_parse' => [$this->fixtureDirModule . 'Model/WithoutDependencies.php'],
|
||||
'config_files' => [$this->fixtureDirModule . 'etc/module.xml'],
|
||||
'declared_namespaces' => ['Magento'],
|
||||
],
|
||||
'write' => ['report_filename' => $this->sourceFilename],
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertFileEquals(
|
||||
$this->fixtureDir . 'expected/without-framework-dependencies.csv',
|
||||
$this->sourceFilename
|
||||
);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists($this->sourceFilename)) {
|
||||
unlink($this->sourceFilename);
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Helper;
|
||||
|
||||
class Helper
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
new Magento\LibFirst();
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
use Magento\LibSecond;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @use Magento\LibSecond()
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
new LibSecond();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
class WithoutDependencies
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_FirstModule"/>
|
||||
</config>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php new Magento\Third();
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "magento/module-module1",
|
||||
"description": "N/A",
|
||||
"require": {
|
||||
"php": "~5.6.0|7.0.2|^7.0.6",
|
||||
"magento/module-module2": "0.1.0-alpha103"
|
||||
},
|
||||
"suggest": {
|
||||
"magento/module-backend": "0.1.0-alpha103"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"version": "0.1.0-alpha103"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "magento/module-module2",
|
||||
"description": "N/A",
|
||||
"require": {
|
||||
"php": "~5.6.0|7.0.2|^7.0.6",
|
||||
"magento/module-module3": "0.1.0-alpha103"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"version": "0.1.0-alpha103"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "magento/module-module1",
|
||||
"description": "N/A",
|
||||
"require": {
|
||||
"php": "~5.6.0|7.0.2|^7.0.6"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"version": "0.1.0-alpha103"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "magento/module-module1",
|
||||
"description": "N/A",
|
||||
"require": {
|
||||
"php": "~5.6.0|7.0.2|^7.0.6",
|
||||
"magento/module-module2": "0.1.0-alpha103"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"version": "0.1.0-alpha103"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "magento/module-module2",
|
||||
"description": "N/A",
|
||||
"require": {
|
||||
"php": "~5.6.0|7.0.2|^7.0.6",
|
||||
"magento/module-module1": "0.1.0-alpha103"
|
||||
},
|
||||
"type": "magento2-module",
|
||||
"version": "0.1.0-alpha103"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"Circular dependencies:","Total number of chains"
|
||||
,2
|
||||
|
||||
"Circular dependencies for each module:",
|
||||
magento/module-module1,1
|
||||
magento/module-module1->magento/module-module2->magento/module-module1
|
||||
|
||||
magento/module-module2,1
|
||||
magento/module-module2->magento/module-module1->magento/module-module2
|
||||
|
+10
@@ -0,0 +1,10 @@
|
||||
,All,Hard,Soft
|
||||
"Total number of dependencies",3,2,1
|
||||
|
||||
"Dependencies for each module:",All,Hard,Soft
|
||||
magento/module-module1,2,1,1
|
||||
" -- magento/module-module2",,1,0
|
||||
" -- magento/module-backend",,0,1
|
||||
|
||||
magento/module-module2,1,1,0
|
||||
" -- magento/module-module3",,1,0
|
||||
|
+8
@@ -0,0 +1,8 @@
|
||||
"Dependencies of framework:","Total number"
|
||||
,3
|
||||
|
||||
"Dependencies for each module:",
|
||||
Magento\FirstModule,3
|
||||
" -- Magento\LibFirst",1
|
||||
" -- Magento\LibSecond",2
|
||||
" -- Magento\Third",1
|
||||
|
+2
@@ -0,0 +1,2 @@
|
||||
"Circular dependencies:","Total number of chains"
|
||||
,0
|
||||
|
+2
@@ -0,0 +1,2 @@
|
||||
,All,Hard,Soft
|
||||
"Total number of dependencies",0,0,0
|
||||
|
+2
@@ -0,0 +1,2 @@
|
||||
"Dependencies of framework:","Total number"
|
||||
,0
|
||||
|
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_Module1">
|
||||
</module>
|
||||
</config>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
|
||||
<module name="Magento_Module2">
|
||||
</module>
|
||||
</config>
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Dictionary;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Magento\Setup\Module\I18n\Dictionary\Generator;
|
||||
use Magento\Setup\Module\I18n\ServiceLocator;
|
||||
|
||||
class GeneratorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $testDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $expectedDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $outputFileName;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Module\I18n\Dictionary\Generator
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backupRegistrar;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$this->backupRegistrar = $paths->getValue();
|
||||
$paths->setValue(['module' => [], 'theme' => []]);
|
||||
$paths->setAccessible(false);
|
||||
|
||||
$this->testDir = realpath(__DIR__ . '/_files');
|
||||
$this->expectedDir = $this->testDir . '/expected';
|
||||
$this->source = $this->testDir . '/source';
|
||||
$this->outputFileName = $this->testDir . '/translate.csv';
|
||||
|
||||
// Register the test modules
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_FirstModule',
|
||||
$this->source . '/app/code/Magento/FirstModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_SecondModule',
|
||||
$this->source . '/app/code/Magento/SecondModule'
|
||||
);
|
||||
|
||||
// Register the test theme
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::THEME,
|
||||
'adminhtml/default/backend',
|
||||
$this->source . '/app/design/adminhtml/default/backend'
|
||||
);
|
||||
|
||||
$this->generator = ServiceLocator::getDictionaryGenerator();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
if (file_exists($this->outputFileName)) {
|
||||
unlink($this->outputFileName);
|
||||
}
|
||||
$property = new \ReflectionProperty(\Magento\Setup\Module\I18n\ServiceLocator::class, '_dictionaryGenerator');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue(null);
|
||||
$property->setAccessible(false);
|
||||
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$paths->setValue($this->backupRegistrar);
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
public function testGenerationWithoutContext()
|
||||
{
|
||||
$this->generator->generate($this->source, $this->outputFileName);
|
||||
|
||||
$this->assertFileEquals($this->expectedDir . '/without_context.csv', $this->outputFileName);
|
||||
}
|
||||
|
||||
public function testGenerationWithContext()
|
||||
{
|
||||
$this->generator->generate($this->source, $this->outputFileName, true);
|
||||
|
||||
$expected = explode(PHP_EOL, file_get_contents($this->expectedDir . '/with_context.csv'));
|
||||
$output = file_get_contents($this->outputFileName);
|
||||
foreach ($expected as $line) {
|
||||
if ($line) {
|
||||
$this->assertStringContainsString($line, $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
Helper,Helper,module,Magento_FirstModule
|
||||
Model,Model,module,Magento_FirstModule
|
||||
"Module template","Module template",module,Magento_FirstModule
|
||||
Model,Model,module,Magento_SecondModule
|
||||
"Theme template","Theme template",theme,adminhtml/default/backend
|
||||
"Module js","Module js",module,Magento_FirstModule
|
||||
"Lib js","Lib js",lib,lib/web/mage/file.js
|
||||
"Lib js","Lib js",lib,lib/web/varien/file.js
|
||||
"Module layout label","Module layout label",module,Magento_FirstModule
|
||||
"Module layout title","Module layout title",module,Magento_FirstModule
|
||||
"Theme layout label","Theme layout label",theme,adminhtml/default/backend
|
||||
"Theme layout title","Theme layout title",theme,adminhtml/default/backend
|
||||
|
+13
@@ -0,0 +1,13 @@
|
||||
Helper,Helper
|
||||
Model,Model
|
||||
"Module template","Module template"
|
||||
"Theme template","Theme template"
|
||||
"Model unused","Model unused"
|
||||
"Theme template unused","Theme template unused"
|
||||
"Module js","Module js"
|
||||
"Lib js","Lib js"
|
||||
"Lib js unused","Lib js unused"
|
||||
"Module layout label","Module layout label"
|
||||
"Module layout title","Module layout title"
|
||||
"Theme layout label","Theme layout label"
|
||||
"Theme layout title","Theme layout title"
|
||||
|
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Helper;
|
||||
|
||||
class Helper
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Helper');
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model');
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding="utf-8" ?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layout>
|
||||
<referenceBlock translate="description, label">
|
||||
<description>Module layout description</description>
|
||||
<label>Module layout label</label>
|
||||
<title translate="true">Module layout title</title>
|
||||
</referenceBlock>
|
||||
</layout>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Module js');
|
||||
});
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Module template');
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\SecondModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model');
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding="utf-8" ?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
|
||||
<layout>
|
||||
<referenceBlock translate="description, label">
|
||||
<description>Theme layout description</description>
|
||||
<label>Theme layout label</label>
|
||||
<title translate="true">Theme layout title</title>
|
||||
</referenceBlock>
|
||||
</layout>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Theme template');
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js')
|
||||
});
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js')
|
||||
});
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\FirstModule\Model;
|
||||
|
||||
class Model
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function test()
|
||||
{
|
||||
__('Model unused');
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
$.mage.__('Lib js unused')
|
||||
});
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php __('Theme template unused');
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Pack;
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
use Magento\Setup\Module\I18n\ServiceLocator;
|
||||
|
||||
class GeneratorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_testDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_expectedDir;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_dictionaryPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_packPath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_locale;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_expectedFiles;
|
||||
|
||||
/**
|
||||
* @var \Magento\Setup\Module\I18n\Pack\Generator
|
||||
*/
|
||||
protected $_generator;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $backupRegistrar;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->_testDir = realpath(__DIR__ . '/_files');
|
||||
$this->_expectedDir = $this->_testDir . '/expected';
|
||||
$this->_dictionaryPath = $this->_testDir . '/source.csv';
|
||||
$this->_packPath = $this->_testDir . '/pack';
|
||||
$this->_locale = 'de_DE';
|
||||
$this->_expectedFiles = [
|
||||
"/app/code/Magento/FirstModule/i18n/{$this->_locale}.csv",
|
||||
"/app/code/Magento/SecondModule/i18n/{$this->_locale}.csv",
|
||||
"/app/design/adminhtml/default/i18n/{$this->_locale}.csv",
|
||||
];
|
||||
|
||||
$this->_generator = ServiceLocator::getPackGenerator();
|
||||
|
||||
\Magento\Framework\System\Dirs::rm($this->_packPath);
|
||||
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$this->backupRegistrar = $paths->getValue();
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
\Magento\Framework\System\Dirs::rm($this->_packPath);
|
||||
$reflection = new \ReflectionClass(\Magento\Framework\Component\ComponentRegistrar::class);
|
||||
$paths = $reflection->getProperty('paths');
|
||||
$paths->setAccessible(true);
|
||||
$paths->setValue($this->backupRegistrar);
|
||||
$paths->setAccessible(false);
|
||||
}
|
||||
|
||||
public function testGeneration()
|
||||
{
|
||||
$this->assertFileDoesNotExist($this->_packPath);
|
||||
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_FirstModule',
|
||||
$this->_packPath . '/app/code/Magento/FirstModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::MODULE,
|
||||
'Magento_SecondModule',
|
||||
$this->_packPath. '/app/code/Magento/SecondModule'
|
||||
);
|
||||
ComponentRegistrar::register(
|
||||
ComponentRegistrar::THEME,
|
||||
'adminhtml/default',
|
||||
$this->_packPath. '/app/design/adminhtml/default'
|
||||
);
|
||||
|
||||
$this->_generator->generate($this->_dictionaryPath, $this->_locale);
|
||||
|
||||
foreach ($this->_expectedFiles as $file) {
|
||||
$this->assertFileEquals($this->_expectedDir . $file, $this->_packPath . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
Helper,Helper
|
||||
Model,Model
|
||||
"Module template","Module template"
|
||||
"Module js","Module js"
|
||||
"Module layout label","Module layout label"
|
||||
"Module layout title","Module layout title"
|
||||
|
+1
@@ -0,0 +1 @@
|
||||
Model,Model
|
||||
|
+3
@@ -0,0 +1,3 @@
|
||||
"Theme template","Theme template"
|
||||
"Theme layout label","Theme layout label"
|
||||
"Theme layout title","Theme layout title"
|
||||
|
+1
@@ -0,0 +1 @@
|
||||
"Lib js","Lib js"
|
||||
|
@@ -0,0 +1,10 @@
|
||||
Helper,Helper,module,Magento_FirstModule
|
||||
Model,Model,module,"Magento_FirstModule,Magento_SecondModule"
|
||||
"Module template","Module template",module,Magento_FirstModule
|
||||
"Theme template","Theme template",theme,adminhtml/default
|
||||
"Module js","Module js",module,Magento_FirstModule
|
||||
"Lib js","Lib js",lib,"lib/web/mage/file.js,lib/web/varien/file.js"
|
||||
"Module layout label","Module layout label",module,Magento_FirstModule
|
||||
"Module layout title","Module layout title",module,Magento_FirstModule
|
||||
"Theme layout label","Theme layout label",theme,adminhtml/default
|
||||
"Theme layout title","Theme layout title",theme,adminhtml/default
|
||||
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Js
|
||||
*
|
||||
*/
|
||||
class JsTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var Js
|
||||
*/
|
||||
protected $jsPhraseCollector;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->jsPhraseCollector = $objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Js::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__ . '/_files/jsPhrasesForTest.js';
|
||||
$this->jsPhraseCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => 'text double quote',
|
||||
'file' => $file,
|
||||
'line' => 1,
|
||||
'quote' => '"'
|
||||
],
|
||||
[
|
||||
'phrase' => 'text single quote',
|
||||
'file' => $file,
|
||||
'line' => 2,
|
||||
'quote' => '\''
|
||||
],
|
||||
[
|
||||
'phrase' => 'text "some',
|
||||
'file' => $file,
|
||||
'line' => 3,
|
||||
'quote' => '\''
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->jsPhraseCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector
|
||||
*/
|
||||
class PhraseCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var PhraseCollector
|
||||
*/
|
||||
protected $phraseCollector;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->phraseCollector = $this->objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\PhraseCollector::parse
|
||||
*/
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__.'/_files/objectsCode.php.txt';
|
||||
$this->phraseCollector->setIncludeObjects();
|
||||
$this->phraseCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => '\'Testing\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 3
|
||||
],
|
||||
[
|
||||
'phrase' => '\'More testing\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 4
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->phraseCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate;
|
||||
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector
|
||||
*/
|
||||
class MethodCollectorTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var MethodCollector
|
||||
*/
|
||||
protected $methodCollector;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
$this->methodCollector = $this->objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Php\Tokenizer\Translate\MethodCollector::parse
|
||||
*/
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__.'/../_files/methodsCode.php.txt';
|
||||
$this->methodCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => '\'Some string\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 4
|
||||
],
|
||||
[
|
||||
'phrase' => '\'One more string\'',
|
||||
'arguments' => 0,
|
||||
'file' => $file,
|
||||
'line' => 5
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->methodCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
$obj1->___toString('Irrelevant string');
|
||||
$obj2->__('Some string');
|
||||
$obj3->__('One more string');
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
new \Magento\Framework\Phrase('Testing');
|
||||
new Phrase('More testing');
|
||||
new \Magento\Framework\DataObject();
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Setup\Module\I18n\Parser\Adapter;
|
||||
|
||||
/**
|
||||
* @covers \Magento\Setup\Module\I18n\Parser\Adapter\Xml
|
||||
*
|
||||
*/
|
||||
class XmlTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var Xml
|
||||
*/
|
||||
protected $xmlPhraseCollector;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$this->xmlPhraseCollector = $objectManager->create(
|
||||
\Magento\Setup\Module\I18n\Parser\Adapter\Xml::class
|
||||
);
|
||||
}
|
||||
|
||||
public function testParse()
|
||||
{
|
||||
$file = __DIR__ . '/_files/xmlPhrasesForTest.xml';
|
||||
$this->xmlPhraseCollector->parse($file);
|
||||
$expectation = [
|
||||
[
|
||||
'phrase' => 'Name only',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
],
|
||||
[
|
||||
'phrase' => 'Name and title space delimiter',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
],
|
||||
[
|
||||
'phrase' => 'title1',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
],
|
||||
[
|
||||
'phrase' => 'title2',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
],
|
||||
[
|
||||
'phrase' => 'Name only in sub node',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
],
|
||||
[
|
||||
'phrase' => 'Text outside of attribute',
|
||||
'file' => $file,
|
||||
'line' => '',
|
||||
'quote' => ''
|
||||
]
|
||||
];
|
||||
$this->assertEquals($expectation, $this->xmlPhraseCollector->getPhrases());
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
$t("text double quote");
|
||||
$t('text single quote');
|
||||
$t('text "some');
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<config>
|
||||
<node name="Name only" translate="name"/>
|
||||
<node name="Name and title space delimiter" title="title1" translate="name title"/>
|
||||
<node name="Name and title comma delimiter" title="title2" translate="name, title"/>
|
||||
<node translate="name">
|
||||
<name>Name only in sub node</name>
|
||||
<notName>This shouldn't be picked up</notName>
|
||||
</node>
|
||||
<node translate="true">Text outside of attribute</node>
|
||||
</config>
|
||||
Reference in New Issue
Block a user