/** * Gets application commands * * @return array */ protected function getApplicationCommands() { $setupCommands = []; $toolsCommands = []; $modulesCommands = []; $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP); $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; $bootstrap = Bootstrap::create(BP, $params); $objectManager = $bootstrap->getObjectManager(); if (class_exists('Magento\\Setup\\Console\\CommandList')) { $serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager(); $setupCommandList = new \Magento\Setup\Console\CommandList($serviceManager); $setupCommands = $setupCommandList->getCommands(); } if (class_exists('Magento\\Tools\\Console\\CommandList')) { $toolsCommandList = new \Magento\Tools\Console\CommandList(); $toolsCommands = $toolsCommandList->getCommands(); } if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) { $commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList'); $modulesCommands = $commandList->getCommands(); } $commandsList = array_merge($setupCommands, $toolsCommands, $modulesCommands); return $commandsList; }
/** * Gets application commands * * @return array */ protected function getApplicationCommands() { $commands = []; try { $bootstrapParam = new ComplexParameter(self::INPUT_KEY_BOOTSTRAP); $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; $bootstrap = Bootstrap::create(BP, $params); $objectManager = $bootstrap->getObjectManager(); /** @var \Magento\Setup\Model\ObjectManagerProvider $omProvider */ $omProvider = $this->serviceManager->get('Magento\\Setup\\Model\\ObjectManagerProvider'); $omProvider->setObjectManager($objectManager); if (class_exists('Magento\\Setup\\Console\\CommandList')) { $setupCommandList = new \Magento\Setup\Console\CommandList($this->serviceManager); $commands = array_merge($commands, $setupCommandList->getCommands()); } if ($objectManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) { /** @var \Magento\Framework\Console\CommandList $commandList */ $commandList = $objectManager->create('Magento\\Framework\\Console\\CommandList'); $commands = array_merge($commands, $commandList->getCommands()); } $commands = array_merge($commands, $this->getVendorCommands($objectManager)); } catch (\Exception $e) { $this->initException = $e; } return $commands; }
public static function setUpBeforeClass() { self::$root = BP; self::$rootJson = json_decode(file_get_contents(self::$root . '/composer.json'), true); self::$dependencies = []; self::$objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager(); }
/** * Bootstraps Magento2 */ public function bootstrapMage2() { if (is_null($this->bootstrap)) { $bootstrap = Bootstrap::create(BP, $_SERVER); $bootstrap->getObjectManager(); $this->bootstrap = true; } }
/** * Setup method */ protected function setUp() { $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); $app = $bootstrap->createApplication('Magento\\Framework\\App\\Http'); $bootstrap->run($app); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->objectManager = ObjectManager::getInstance(); }
/** * 2016-11-03 * @override * @see \PHPUnit\Framework\TestCase::setUp() * @return void */ protected function setUp() { if (!self::$r) { self::$r = true; Bootstrap::create(BP, $_SERVER)->createApplication(Http::class); df_app_state()->setAreaCode('frontend'); } }
/** * @test * @covers \Yireo\NewRelic2\Helper\Data::isAdmin */ public function testIsAdmin() { $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); /** @var \Magento\Framework\App\Http $app */ $bootstrap->createApplication('Magento\\Framework\\App\\Http'); $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $appState = $objectManager->get('Magento\\Framework\\App\\State'); $backendAreaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE; $appState->setAreaCode($backendAreaCode); $this->assertTrue($this->targetHelper->isAdmin()); }
public function initMagento() { $bootstrapPath = $this->config->getMagentoBootstrapPath(); if (!file_exists($bootstrapPath)) { throw new \RuntimeException(sprintf("Magento's bootstrap file was not found at path '%s'", $bootstrapPath)); } include $bootstrapPath; $params = $_SERVER; $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload']]; putenv('BEHAT_RUNNING=true'); $bootstrap = Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\\Framework\\App\\Http'); $app->launch(); ObjectManager::getInstance(); $this->magentoConfigManager = new MagentoConfigManager(); $this->magentoConfigManager->changeConfigs($this->config->getRequiredMagentoConfig()); }
public function testUnitTestFilesPlacement() { $objectManager = Bootstrap::create(BP, $_SERVER)->getObjectManager(); /** @var \Magento\Framework\Data\Collection\Filesystem $filesystem */ $filesystem = $objectManager->get('Magento\\Framework\\Data\\Collection\\Filesystem'); $filesystem->setCollectDirs(false)->setCollectFiles(true)->setCollectRecursively(true); $targetsExist = false; foreach ($this->scanList as $dir) { if (realpath($this->root . DIRECTORY_SEPARATOR . $dir)) { $filesystem->addTargetDir($this->root . DIRECTORY_SEPARATOR . $dir); $targetsExist = true; } } if ($targetsExist) { $files = $filesystem->load()->toArray(); $fileList = []; foreach ($files['items'] as $file) { $fileList[] = $file['filename']; } $this->assertEquals(0, $files['totalRecords'], "The following files have been found in obsolete test directories: \n" . implode("\n", $fileList)); } }
/** * Performance framework bootstrap script * * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ $testsBaseDir = dirname(__DIR__); require __DIR__ . '/../../../../app/bootstrap.php'; $appBootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); (new \Magento\Framework\Autoload\IncludePath())->addIncludePath($testsBaseDir . '/framework'); $bootstrap = new \Magento\TestFramework\Performance\Bootstrap($appBootstrap, $testsBaseDir); $bootstrap->cleanupReports(); return $bootstrap;
<?php /** * Public alias for the application entry point * * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ use Magento\Framework\App\Bootstrap; use Magento\Framework\App\Filesystem\DirectoryList; try { require __DIR__ . '/../app/bootstrap.php'; } catch (\Exception $e) { echo <<<HTML <div style="font:12px/1.35em arial, helvetica, sans-serif;"> <div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;"> <h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;"> Autoload error</h3> </div> <p>{$e->getMessage()}</p> </div> HTML; exit(1); } $params = $_SERVER; $params[Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS] = [DirectoryList::PUB => [DirectoryList::URL_PATH => ''], DirectoryList::MEDIA => [DirectoryList::URL_PATH => 'media'], DirectoryList::STATIC_VIEW => [DirectoryList::URL_PATH => 'static'], DirectoryList::UPLOAD => [DirectoryList::URL_PATH => 'media/upload']]; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\\Framework\\App\\Http'); $bootstrap->run($app);
/** * @return void */ protected function _initMagento2() { require_once $this->getMagentoRootFolder() . '/app/bootstrap.php'; $params = $_SERVER; $params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE] = 'admin'; $params[\Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM] = true; $params['entryPoint'] = basename(__FILE__); $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); /** @var \Magento\Framework\App\Cron $app */ $app = $bootstrap->createApplication('N98\\Magento\\Framework\\App\\Magerun', []); /* @var $app \N98\Magento\Framework\App\Magerun */ $app->launch(); $this->_objectManager = $app->getObjectManager(); }
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ use Magento\Framework\App\Bootstrap; use Magento\Framework\App\State; use Magento\Framework\Shell\ComplexParameter; require_once __DIR__ . '/../../../../../app/bootstrap.php'; $usage = 'Usage: php -f install.php -- --admin_username= [--bootstrap=] --admin_username - store\'s admin username. Required for installation. [--bootstrap] - add or override parameters of the bootstrap' . PHP_EOL; $data = getopt('', ['admin_username:'******'bootstrap::']); if (!isset($data['admin_username']) || empty($data['admin_username'])) { echo $usage; exit(1); } $bootstrapParam = new ComplexParameter('bootstrap'); $params = $bootstrapParam->mergeFromArgv($_SERVER, $_SERVER); $params[Bootstrap::PARAM_REQUIRE_MAINTENANCE] = null; $params[State::PARAM_MODE] = State::MODE_DEVELOPER; $bootstrap = Bootstrap::create(BP, $params); $app = $bootstrap->createApplication('Magento\\Tools\\SampleData\\InstallerApp', ['data' => $data]); $bootstrap->run($app);
* $bootstrap = new \Magento\Framework\App\Bootstrap(BP, $_SERVER, $extra); * $app = $bootstrap->createApplication('Magento\Framework\App\Http'); * $bootstrap->run($app); * -------------------------------------------- * * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Magento to newer * versions in the future. If you wish to customize Magento for your * needs please refer to http://www.magentocommerce.com for more information. * * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ require __DIR__ . '/app/bootstrap.php'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER, null); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('Magento\\Framework\\App\\Http'); $bootstrap->run($app);
<?php use Magento\Framework\Autoload\AutoloaderRegistry; use Magento\Framework\Autoload\ClassLoaderWrapper; use Magento\Framework\App\State; umask(0); error_reporting(E_ALL); date_default_timezone_set('UTC'); /** * Shortcut constant for the root directory */ define('BP', dirname(__DIR__)); $autoloader = (require BP . '/vendor/autoload.php'); AutoloaderRegistry::registerAutoloader(new ClassLoaderWrapper($autoloader)); // Sets default autoload mappings, may be overridden in Bootstrap::create \Magento\Framework\App\Bootstrap::populateAutoloader(BP, []); $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, [State::PARAM_MODE => State::MODE_DEVELOPER]); return $bootstrap;
<?php include 'app/bootstrap.php'; include ‘createcommon . php’; use Magento\Framework\App\Bootstrap; $bootstrap = Bootstrap::create(BP, $_SERVER); $objectManager = $bootstrap->getObjectManager(); $state = $objectManager->get('Magento\\Framework\\App\\State'); $state->setAreaCode('frontend'); try { $_product = createProduct((int) $argv[2], (int) $argv[3]); echo "Success: Product Id: " . $_product->getId(); exit; } catch (Exception $e) { print_r($e->getMessage()); }