/** * Returns the current context. * * @param boolean $locale True to add locale object to context, false if not * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Standard($config); $context->setFilesystemManager($fs); $container = $this->container; $mail = new \Aimeos\MW\Mail\Swift(function () use($container) { return $container->get('mailer'); }); $context->setMail($mail); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n($this->container->get('aimeos_i18n')->get(array($langid))); } $session = new \Aimeos\MW\Session\Symfony2($this->container->get('session')); $context->setSession($session); $this->addUser($context); return $context; }
/** * Returns a new context object * * @param array $confPaths List of configuration paths from the bootstrap object * @param array $options Associative list of configuration options as key/value pairs * @return \Aimeos\MShop\Context\Item\Iface Context object */ protected static function getContext(array $confPaths, array $options) { $config = array(); $ctx = new \Aimeos\MShop\Context\Item\Standard(); if (isset($options['config'])) { foreach ((array) $options['config'] as $path) { if (is_file($path)) { $config = array_replace_recursive($config, require $path); } else { $confPaths[] = $path; } } } $conf = new \Aimeos\MW\Config\PHPArray($config, $confPaths); $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); if (($cfg = $conf->get('command')) !== null) { $conf = new \Aimeos\MW\Config\Decorator\Memory($conf, $cfg); } $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $logger = new \Aimeos\MW\Logger\Errorlog(\Aimeos\MW\Logger\Base::INFO); $ctx->setLogger($logger); return $ctx; }
/** * @param string $site */ private static function createContext($site) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $aimeos = self::getAimeos(); $paths = $aimeos->getConfigPaths('mysql'); $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); $ctx->setLogger($logger); $cache = new \Aimeos\MW\Cache\None(); $ctx->setCache($cache); $i18n = new \Aimeos\MW\Translation\None('de'); $ctx->setI18n(array('de' => $i18n)); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $locale = $localeManager->bootstrap($site, '', '', false); $ctx->setLocale($locale); $ctx->setEditor('core:admin/jqadm'); return $ctx; }
/** * Returns the current context. * * @param \TYPO3\Flow\Mvc\RequestInterface $request Request object * @return \Aimeos\MShop\Context\Item\Iface */ public function get(\TYPO3\Flow\Mvc\RequestInterface $request = null, $type = 'frontend') { $config = $this->config->get($type); if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); self::$context = $context; } $context = self::$context; $context->setConfig($config); if ($request !== null) { $localeItem = $this->locale->get($context, $request); $context->setI18n($this->i18n->get(array($localeItem->getLanguageId()))); $context->setLocale($localeItem); } $this->addSession($context); $this->addUser($context); return $context; }
/** * @test */ public function getOutput() { $aimeos = new \Aimeos\Shop\Base\Aimeos(); $this->inject($this->object, 'aimeos', $aimeos); $context = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Context')->setMethods(array('get'))->disableOriginalConstructor()->getMock(); $ctx = new \Aimeos\MShop\Context\Item\Standard(); $ctx->setConfig(new \Aimeos\MW\Config\PHPArray()); $ctx->setLocale(new \Aimeos\MShop\Locale\Item\Standard(array('langid' => 'de'))); $context->expects($this->once())->method('get')->will($this->returnValue($ctx)); $this->inject($this->object, 'context', $context); $viewContainer = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\View')->setMethods(array('create'))->disableOriginalConstructor()->getMock(); $mwView = new \Aimeos\MW\View\Standard(); $viewContainer->expects($this->once())->method('create')->will($this->returnValue($mwView)); $this->inject($this->object, 'viewContainer', $viewContainer); $uriBuilder = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\Routing\\UriBuilder')->disableOriginalConstructor()->getMock(); $this->inject($this->object, 'uriBuilder', $uriBuilder); $client = $this->getMockBuilder('\\Aimeos\\Client\\Html\\Catalog\\Lists\\Standard')->setMethods(array('getBody', 'getHeader', 'process'))->disableOriginalConstructor()->getMock(); $client->expects($this->once())->method('getBody')->will($this->returnValue('body')); $client->expects($this->once())->method('getHeader')->will($this->returnValue('header')); $client->expects($this->once())->method('process'); \Aimeos\Client\Html\Catalog\Lists\Factory::injectClient('\\Aimeos\\Client\\Html\\Catalog\\Lists\\Standard', $client); $this->view->expects($this->once())->method('assign')->with($this->equalTo('aimeos_component_header'), $this->equalTo('header')); $class = new \ReflectionClass('\\Aimeos\\Shop\\Controller\\AbstractController'); $method = $class->getMethod('getOutput'); $method->setAccessible(true); $result = $method->invokeArgs($this->object, array('catalog/lists')); $this->assertEquals('body', $result); }
/** * Returns the current context. * * @param boolean $locale True to add locale object to context, false if not * @param string $type Configuration type ("frontend" or "backend") * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true, $type = 'frontend') { $config = $this->container->get('aimeos_config')->get($type); if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($config); $this->addDataBaseManager($context); $this->addFilesystemManager($context); $this->addMessageQueueManager($context); $this->addLogger($context); $this->addCache($context); $this->addMailer($context); self::$context = $context; } $context = self::$context; $context->setConfig($config); if ($locale === true) { $localeItem = $this->container->get('aimeos_locale')->get($context); $context->setI18n($this->container->get('aimeos_i18n')->get(array($localeItem->getLanguageId()))); $context->setLocale($localeItem); } $this->addSession($context); $this->addUserGroups($context); return $context; }
/** * Returns the current context * * @param boolean $locale True to add locale object to context, false if not * @return \Aimeos\MShop\Context\Item\Iface Context object */ public function get($locale = true) { if (self::$context === null) { $context = new \Aimeos\MShop\Context\Item\Standard(); $config = $this->getConfig(); $context->setConfig($config); $dbm = new \Aimeos\MW\DB\Manager\PDO($config); $context->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Laravel(app('filesystem'), $config, storage_path('aimeos')); $context->setFilesystemManager($fs); $mail = new \Aimeos\MW\Mail\Swift(function () { return app('mailer')->getSwiftMailer(); }); $context->setMail($mail); $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); $context->setLogger($logger); $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); $context->setCache($cache); self::$context = $context; } $context = self::$context; if ($locale === true) { $localeItem = $this->getLocale($context); $langid = $localeItem->getLanguageId(); $context->setLocale($localeItem); $context->setI18n(app('\\Aimeos\\Shop\\Base\\I18n')->get(array($langid))); } $session = new \Aimeos\MW\Session\Laravel5($this->session); $context->setSession($session); $this->addUser($context); return $context; }
/** * @param string $site */ private static function createContext($site) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $aimeos = self::getAimeos(); $paths = $aimeos->getConfigPaths('mysql'); $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; $local = array('resource' => array('fs' => array('adapter' => 'Standard', 'basedir' => __DIR__ . '/tmp'))); $conf = new \Aimeos\MW\Config\PHPArray($local, $paths); $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); $ctx->setConfig($conf); $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); $ctx->setLogger($logger); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf); $ctx->setFilesystemManager($fs); $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); $ctx->setMessageQueueManager($mq); $cache = new \Aimeos\MW\Cache\None(); $ctx->setCache($cache); $i18n = new \Aimeos\MW\Translation\None('de'); $ctx->setI18n(array('de' => $i18n)); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $locale = $localeManager->bootstrap($site, '', '', false); $ctx->setLocale($locale); $ctx->setEditor('core:client/html'); return $ctx; }
public function testCreateNoLocale() { $i18n = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\I18n')->disableOriginalConstructor()->getMock(); $support = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Support')->disableOriginalConstructor()->getMock(); $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig(new \Aimeos\MW\Config\PHPArray()); $object = new \Aimeos\Shop\Base\View($i18n, $support); $this->assertInstanceOf('\\Aimeos\\MW\\View\\Iface', $object->create($context, array())); }
/** * @test */ public function createWithRequest() { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig(new \Aimeos\MW\Config\PHPArray()); $uriBuilder = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\Routing\\UriBuilder')->disableOriginalConstructor()->getMock(); $httpRequest = new \TYPO3\Flow\Http\Request(array(), array(), array(), array()); $request = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\ActionRequest')->setMethods(array('getArguments', 'getHttpRequest'))->disableOriginalConstructor()->getMock(); $request->expects($this->exactly(2))->method('getArguments')->will($this->returnValue(array('site' => 'unittest', 'locale' => 'de', 'currency' => 'EUR'))); $request->expects($this->once())->method('getHttpRequest')->will($this->returnValue($httpRequest)); $view = $this->object->create($context, $uriBuilder, array(), $request, 'de'); $this->assertInstanceOf('\\Aimeos\\MW\\View\\Iface', $view); }
/** * Returns a bare context object * * @return \Aimeos\MShop\Context\Item\Standard Context object containing only the most necessary dependencies */ protected function getBareContext() { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $conf = new \Aimeos\MW\Config\PHPArray(array(), array()); $ctx->setConfig($conf); $locale = \Aimeos\MShop\Factory::createManager($ctx, 'locale')->createItem(); $locale->setLanguageId('en'); $ctx->setLocale($locale); $i18n = new \Aimeos\MW\Translation\Zend2(array(), 'gettext', 'en', array('disableNotices' => true)); $ctx->setI18n(array('en' => $i18n)); return $ctx; }
/** * Returns a new context object * * @param \Aimeos\MW\Config\Iface $conf Configuration object * @return \Aimeos\MShop\Context\Item\Iface New context object */ function getContext(\Aimeos\MW\Config\Iface $conf) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf); $ctx->setDatabaseManager($dbm); $logger = new \Aimeos\MW\Logger\Errorlog(\Aimeos\MW\Logger\Base::INFO); $ctx->setLogger($logger); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $cache = new \Aimeos\MW\Cache\None(); $ctx->setCache($cache); return $ctx; }
/** * Creates a new context item. * * @param string $site Unique site code * @return \\Aimeos\MShop\Context\Item\Iface Context object */ private static function createContext($site) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $mshop = self::getAimeos(); $paths = $mshop->getConfigPaths('mysql'); $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); $ctx->setLogger($logger); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $localeItem = $localeManager->bootstrap($site, '', '', false); $ctx->setLocale($localeItem); $ctx->setEditor('zend:unittest'); return $ctx; }
/** * @test */ public function get() { $view = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\View')->setMethods(array('create'))->disableOriginalConstructor()->getMock(); $mwView = new \Aimeos\MW\View\Standard(); $view->expects($this->once())->method('create')->will($this->returnValue($mwView)); $this->inject($this->object, 'view', $view); $context = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Context')->setMethods(array('get'))->disableOriginalConstructor()->getMock(); $ctx = new \Aimeos\MShop\Context\Item\Standard(); $ctx->setConfig(new \Aimeos\MW\Config\PHPArray()); $ctx->setLocale(new \Aimeos\MShop\Locale\Item\Standard(array('langid' => 'de'))); $context->expects($this->once())->method('get')->will($this->returnValue($ctx)); $this->inject($this->object, 'context', $context); $settings = array('flow' => array('cache' => array('name' => 'None')), 'page' => array()); $this->inject($this->object, 'settings', $settings); $request = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\ActionRequest')->setMethods(array('getArguments'))->disableOriginalConstructor()->getMock(); $result = $this->object->getSections($request, 'catalog/list'); $this->assertInternalType('array', $result); $this->assertArrayHasKey('aibody', $result); $this->assertArrayHasKey('aiheader', $result); }
/** * @param string $site */ private static function createContext($site) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $aimeos = self::getAimeos(); $paths = $aimeos->getConfigPaths('mysql'); $paths[] = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config'; $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); $ctx->setLogger($logger); $i18n = new \Aimeos\MW\Translation\None('de'); $ctx->setI18n(array('de' => $i18n)); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $localeItem = $localeManager->bootstrap($site, '', '', false); $ctx->setLocale($localeItem); $ctx->setEditor('ai-monolog:lib/custom'); return $ctx; }
/** * @test */ public function doAction() { $this->object = $this->getMockBuilder('\\Aimeos\\Shop\\Controller\\ExtadmController')->setMethods(array('getJsonSiteItem'))->disableOriginalConstructor()->getMock(); $aimeos = new \Aimeos\Shop\Base\Aimeos(); $this->inject($this->object, 'aimeos', $aimeos); $view = new \Aimeos\Shop\Base\View(); $this->inject($this->object, 'viewcontainer', $view); $context = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Context')->disableOriginalConstructor()->setMethods(array('get'))->getMock(); $ctx = new \Aimeos\MShop\Context\Item\Standard(); $ctx->setConfig(new \Aimeos\MW\Config\PHPArray()); $context->expects($this->once())->method('get')->will($this->returnValue($ctx)); $this->inject($this->object, 'context', $context); $locale = $this->getMockBuilder('\\Aimeos\\Shop\\Base\\Locale')->setMethods(array('getBackend'))->disableOriginalConstructor()->getMock(); $loc = new \Aimeos\MShop\Locale\Item\Standard(); $locale->expects($this->once())->method('getBackend')->will($this->returnValue($loc)); $this->inject($this->object, 'locale', $locale); $uriBuilder = $this->getMockBuilder('\\TYPO3\\Flow\\Mvc\\Routing\\UriBuilder')->setMethods(array('uriFor'))->disableOriginalConstructor()->getMock(); $this->inject($this->object, 'uriBuilder', $uriBuilder); $request = new \TYPO3\Flow\Http\Request(array(), array(), array(), array()); $this->request->expects($this->once())->method('getHttpRequest')->will($this->returnValue($request)); $this->request->expects($this->any())->method('getArguments')->will($this->returnValue(array())); $this->inject($this->object, 'request', $this->request); $this->assertStringStartsWith('{', $this->object->doAction()); }
/** * @param string $site */ private static function createContext($site) { $ctx = new \Aimeos\MShop\Context\Item\Standard(); $aimeos = self::getAimeos(); $paths = $aimeos->getConfigPaths(); $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); $ctx->setConfig($conf); $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); $ctx->setDatabaseManager($dbm); $fs = new \Aimeos\MW\Filesystem\Manager\Standard($conf); $ctx->setFilesystemManager($fs); $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); $ctx->setLogger($logger); $session = new \Aimeos\MW\Session\None(); $ctx->setSession($session); $i18n = new \Aimeos\MW\Translation\None('de'); $ctx->setI18n(array('de' => $i18n)); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); $locale = $localeManager->bootstrap($site, '', '', false); $ctx->setLocale($locale); $ctx->setEditor('phpexcel:controller/extjs'); return $ctx; }
public function testSaveItemInvalidContext() { $context = new \Aimeos\MShop\Context\Item\Standard(); $context->setConfig($this->context->getConfig()); $object = new \Aimeos\MShop\Customer\Manager\Ezpublish($context); $this->setExpectedException('\\Aimeos\\MShop\\Customer\\Exception'); $object->saveItem(new \Aimeos\MShop\Customer\Item\Standard($this->address)); }
require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; $aimeos = new \Aimeos\Bootstrap(isset($options['extdir']) ? (array) $options['extdir'] : array()); $taskPaths = $aimeos->getSetupPaths($parent); $includePaths = $taskPaths; $includePaths[] = get_include_path(); if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) { throw new \Exception('Unable to extend include path'); } $ctx = new \Aimeos\MShop\Context\Item\Standard(); $confPaths = $aimeos->getConfigPaths('mysql'); if (isset($options['config'])) { $confPaths = array_merge($confPaths, (array) $options['config']); } $conf = new \Aimeos\MW\Config\PHPArray(array(), $confPaths); $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); $ctx->setConfig($conf); $conf->set('setup/site', $site); if (isset($options['option'])) { foreach ((array) $options['option'] as $option) { $parts = explode(':', $option); if (count($parts) !== 2) { printf("Invalid config option \"%1\$s\"\n", $option); usage(); } $conf->set($parts[0], $parts[1]); } } $dbconfig = $conf->get('resource', array()); foreach ($dbconfig as $rname => $dbconf) { if (strncmp($rname, 'db', 2) !== 0) { unset($dbconfig[$rname]);