Beispiel #1
0
 public function testRoutes()
 {
     $app = new \Slim\App();
     $boot = new \Aimeos\Slim\Bootstrap($app, array());
     $result = $boot->routes(dirname(__DIR__) . '/src/aimeos-routes.php');
     $this->assertInstanceOf('\\Aimeos\\Slim\\Bootstrap', $result);
 }
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']);
 }