Example #1
0
 public function testPopulateMappings()
 {
     $mockAutoloader = $this->getMockBuilder('\\Magento\\Framework\\Autoload\\AutoloaderInterface')->disableOriginalConstructor()->getMock();
     $mockAutoloader->expects($this->at(0))->method('addPsr4')->with('Magento\\', [DirectoryList::GENERATION . '/Magento/'], true);
     $mockAutoloader->expects($this->at(1))->method('addPsr0')->with('Cm_', DirectoryList::LIB_INTERNAL, true);
     $mockAutoloader->expects($this->at(2))->method('addPsr0')->with('Credis_', DirectoryList::LIB_INTERNAL, true);
     $mockAutoloader->expects($this->at(3))->method('addPsr0')->with('', [DirectoryList::GENERATION]);
     Populator::populateMappings($mockAutoloader, $this->mockDirectoryList);
 }
Example #2
0
 /**
  * Populates autoloader with mapping info
  *
  * @param string $rootDir
  * @param array $initParams
  * @return void
  */
 public static function populateAutoloader($rootDir, $initParams)
 {
     $dirList = self::createFilesystemDirectoryList($rootDir, $initParams);
     $autoloadWrapper = AutoloaderRegistry::getAutoloader();
     Populator::populateMappings($autoloadWrapper, $dirList);
 }
 /**
  * Constructor
  *
  * @param \Magento\Framework\Shell $shell
  * @param string $installDir
  * @param array $installConfigFile
  * @param string $globalConfigFile
  * @param string $globalConfigDir
  * @param string $appMode
  * @param AutoloaderInterface $autoloadWrapper
  * @param bool|null $loadTestExtensionAttributes
  */
 public function __construct(\Magento\Framework\Shell $shell, $installDir, $installConfigFile, $globalConfigFile, $globalConfigDir, $appMode, AutoloaderInterface $autoloadWrapper, $loadTestExtensionAttributes = false)
 {
     if (getcwd() != BP . '/dev/tests/integration') {
         chdir(BP . '/dev/tests/integration');
     }
     $this->_shell = $shell;
     $this->installConfigFile = $installConfigFile;
     $this->_globalConfigDir = realpath($globalConfigDir);
     $this->_appMode = $appMode;
     $this->installDir = $installDir;
     $this->loadTestExtensionAttributes = $loadTestExtensionAttributes;
     $customDirs = $this->getCustomDirs();
     $this->dirList = new \Magento\Framework\App\Filesystem\DirectoryList(BP, $customDirs);
     \Magento\Framework\Autoload\Populator::populateMappings($autoloadWrapper, $this->dirList);
     $this->_initParams = [\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => $customDirs, \Magento\Framework\App\State::PARAM_MODE => $appMode];
     $driverPool = new \Magento\Framework\Filesystem\DriverPool();
     $configFilePool = new \Magento\Framework\Config\File\ConfigFilePool();
     $this->_factory = new \Magento\TestFramework\ObjectManagerFactory($this->dirList, $driverPool, $configFilePool);
     $this->_configDir = $this->dirList->getPath(DirectoryList::CONFIG);
     $this->globalConfigFile = $globalConfigFile;
 }
Example #4
0
 protected function constructObjectManager()
 {
     global $autoloader;
     $magentoAutoloader = new Autoload\ClassLoaderWrapper($autoloader);
     Autoload\AutoloaderRegistry::registerAutoloader($magentoAutoloader);
     /* Overwrite all directories that are used by our module. A correct
        config path is required for a working object manager. */
     $dirList = new DirectoryList($this->useRoot ? BP : $this->getVfs(), [DirectoryList::CONFIG => ["path" => BP . "/app/etc"], DirectoryList::MEDIA => ["path" => $this->getVfs() . "/media"], DirectoryList::VAR_DIR => ["path" => $this->getVfs() . "/var"], DirectoryList::CACHE => ["path" => BP . "/cache"]]);
     Autoload\Populator::populateMappings($magentoAutoloader, $dirList, new ComponentRegistrar());
     $factory = new ObjectManagerFactory($dirList, new DriverPool(), new ConfigFilePool());
     $config = [State::PARAM_MODE => State::MODE_DEVELOPER, "MAGE_CONFIG" => ["db" => ["connection" => ["default" => ["host" => "127.0.0.1", "dbname" => "magento2_test", "username" => "root", "password" => ""]]], "resource" => ["default_setup" => ["connection" => "default"]], "modules" => ["Magento_Authorization" => 1, "Magento_Backend" => 1, "Magento_Config" => 1, "Magento_Developer" => 1, "Magento_Email" => 1, "Magento_MediaStorage" => 1, "Magento_Store" => 1, "Magento_Theme" => 1, "Magento_Translation" => 1, "Magento_Ui" => 1, "Tinify_CompressImages" => 1]]];
     $objectManager = $factory->create($config);
     return $objectManager;
 }