Beispiel #1
0
 public function testSetup()
 {
     $app = new \Slim\App();
     $c = $app->getContainer();
     $boot = new \Aimeos\Slim\Bootstrap($app, array('apc_enabled' => true));
     $boot->setup('.');
     $this->assertInstanceOf('\\Aimeos\\Bootstrap', $c['aimeos']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\Config', $c['aimeos_config']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\Context', $c['aimeos_context']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\Locale', $c['aimeos_locale']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\I18n', $c['aimeos_i18n']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\Page', $c['aimeos_page']);
     $this->assertInstanceOf('\\Aimeos\\Slim\\Base\\View', $c['aimeos_view']);
     $this->assertInstanceOf('\\Swift_Mailer', $c['mailer']);
 }
Beispiel #2
0
 public function call($method, $path, $params = array(), $body = '')
 {
     $app = new \Slim\App(array('settings' => array('determineRouteBeforeAppMiddleware' => true)));
     $settings = array('disableSites' => false, 'routes' => array('admin' => '/{site}/admin', 'account' => '/{site}', 'default' => '/{site}', 'confirm' => '/{site}', 'update' => '/{site}'));
     $boot = new \Aimeos\Slim\Bootstrap($app, $settings);
     $boot->setup(dirname(__DIR__) . '/ext')->routes(dirname(__DIR__) . '/src/aimeos-routes.php');
     $c = $app->getContainer();
     $env = \Slim\Http\Environment::mock(array('REQUEST_METHOD' => $method, 'REQUEST_URI' => $path, 'QUERY_STRING' => http_build_query($params)));
     $c['request'] = \Slim\Http\Request::createFromEnvironment($env);
     $c['request']->getBody()->write($body);
     $c['response'] = new \Slim\Http\Response();
     $twigconf = array('cache' => sys_get_temp_dir() . '/aimeos-slim-twig-cache');
     $c['view'] = new \Slim\Views\Twig(dirname(__DIR__) . '/templates', $twigconf);
     $c['view']->addExtension(new \Slim\Views\TwigExtension($c['router'], $c['request']->getUri()));
     return $app->run(true);
 }
Beispiel #3
0
 /**
  * Executes the command
  *
  * @param array $argv Associative array from $_SERVER['argv']
  */
 public static function run(array $argv)
 {
     array_shift($argv);
     $options = self::getOptions($argv);
     if (($jobs = array_shift($argv)) === null) {
         throw new \Aimeos\Slim\Command\Exception();
     }
     $sites = array_shift($argv);
     $config = self::getConfig($options);
     $app = new \Slim\App($config);
     $aimeos = new \Aimeos\Slim\Bootstrap($app, $config);
     $aimeos->setup(isset($options['extdir']) ? $options['extdir'] : './ext')->routes(isset($options['routes']) ? $options['routes'] : './src/aimeos-routes.php');
     $container = $app->getContainer();
     $context = self::getContext($container);
     $siteItems = self::getSiteItems($context, $sites);
     self::execute($container->get('aimeos'), $context, $siteItems, $jobs);
 }
Beispiel #4
0
 public function testGetSections()
 {
     $app = new \Slim\App(array());
     $basedir = dirname(dirname(__DIR__));
     $settings = (require $basedir . '/src/aimeos-default.php');
     $settings['page']['test'] = array('catalog/filter', 'basket/mini');
     $settings['disableSites'] = false;
     $boot = new \Aimeos\Slim\Bootstrap($app, $settings);
     $boot->setup($basedir . '/ext')->routes($basedir . '/src/aimeos-routes.php');
     $response = new \Slim\Http\Response();
     $request = \Slim\Http\Request::createFromEnvironment(\Slim\Http\Environment::mock());
     $object = new \Aimeos\Slim\Base\Page($app->getContainer());
     $result = $object->getSections('test', $request, $response, array('site' => 'unittest'));
     $this->assertArrayHasKey('aiheader', $result);
     $this->assertArrayHasKey('aibody', $result);
     $this->assertArrayHasKey('catalog/filter', $result['aibody']);
     $this->assertArrayHasKey('catalog/filter', $result['aiheader']);
     $this->assertArrayHasKey('basket/mini', $result['aibody']);
     $this->assertArrayHasKey('basket/mini', $result['aiheader']);
 }