@@ -4,17 +4,17 @@ |
||
4 | 4 | * Set error reporting to maximum |
5 | 5 | */ |
6 | 6 | error_reporting( -1 ); |
7 | -ini_set( 'display_errors', true ); |
|
7 | +ini_set('display_errors', true); |
|
8 | 8 | |
9 | -date_default_timezone_set( 'UTC' ); |
|
9 | +date_default_timezone_set('UTC'); |
|
10 | 10 | |
11 | 11 | /* |
12 | 12 | * Set locale settings to reasonable defaults |
13 | 13 | */ |
14 | -setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
15 | -setlocale( LC_CTYPE, 'en_US.UTF-8' ); |
|
16 | -setlocale( LC_NUMERIC, 'POSIX' ); |
|
17 | -setlocale( LC_TIME, 'POSIX' ); |
|
14 | +setlocale(LC_ALL, 'en_US.UTF-8'); |
|
15 | +setlocale(LC_CTYPE, 'en_US.UTF-8'); |
|
16 | +setlocale(LC_NUMERIC, 'POSIX'); |
|
17 | +setlocale(LC_TIME, 'POSIX'); |
|
18 | 18 | |
19 | 19 | |
20 | 20 | require_once 'TestHelper.php'; |
@@ -65,8 +65,7 @@ |
||
65 | 65 | $this->env->setLoader( $loader ); |
66 | 66 | |
67 | 67 | return $content; |
68 | - } |
|
69 | - catch( \Exception $e ) |
|
68 | + } catch( \Exception $e ) |
|
70 | 69 | { |
71 | 70 | $this->env->setLoader( $loader ); |
72 | 71 | throw $e; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param \Twig_Environment $env Twig environment object |
29 | 29 | */ |
30 | - public function __construct( \Twig_Environment $env ) |
|
30 | + public function __construct(\Twig_Environment $env) |
|
31 | 31 | { |
32 | 32 | $this->env = $env; |
33 | 33 | } |
@@ -42,33 +42,33 @@ discard block |
||
42 | 42 | * @return string Output generated by the template |
43 | 43 | * @throws \Aimeos\MW\View\Exception If the template isn't found |
44 | 44 | */ |
45 | - public function render( \Aimeos\MW\View\Iface $view, $filename, array $values ) |
|
45 | + public function render(\Aimeos\MW\View\Iface $view, $filename, array $values) |
|
46 | 46 | { |
47 | 47 | $loader = $this->env->getLoader(); |
48 | 48 | |
49 | - if( ( $content = @file_get_contents( $filename ) ) === false ) { |
|
50 | - throw new \Aimeos\MW\View\Exception( sprintf( 'Template "%1$s" not found', $filename ) ); |
|
49 | + if (($content = @file_get_contents($filename)) === false) { |
|
50 | + throw new \Aimeos\MW\View\Exception(sprintf('Template "%1$s" not found', $filename)); |
|
51 | 51 | } |
52 | 52 | |
53 | - $custom = new \Twig_Loader_Array( array( $filename => $content ) ); |
|
54 | - $this->env->setLoader( new \Twig_Loader_Chain( array( $custom, $loader ) ) ); |
|
53 | + $custom = new \Twig_Loader_Array(array($filename => $content)); |
|
54 | + $this->env->setLoader(new \Twig_Loader_Chain(array($custom, $loader))); |
|
55 | 55 | |
56 | 56 | try |
57 | 57 | { |
58 | - $template = $this->env->loadTemplate( $filename ); |
|
59 | - $content = $template->render( $values ); |
|
58 | + $template = $this->env->loadTemplate($filename); |
|
59 | + $content = $template->render($values); |
|
60 | 60 | |
61 | - foreach( $template->getBlockNames( $values ) as $key ) { |
|
62 | - $view->block()->set( str_replace( '_', '/', $key ), $template->renderBlock( $key, $values ) ); |
|
61 | + foreach ($template->getBlockNames($values) as $key) { |
|
62 | + $view->block()->set(str_replace('_', '/', $key), $template->renderBlock($key, $values)); |
|
63 | 63 | } |
64 | 64 | |
65 | - $this->env->setLoader( $loader ); |
|
65 | + $this->env->setLoader($loader); |
|
66 | 66 | |
67 | 67 | return $content; |
68 | 68 | } |
69 | - catch( \Exception $e ) |
|
69 | + catch (\Exception $e) |
|
70 | 70 | { |
71 | - $this->env->setLoader( $loader ); |
|
71 | + $this->env->setLoader($loader); |
|
72 | 72 | throw $e; |
73 | 73 | } |
74 | 74 | } |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $includepaths = $aimeos->getIncludePaths(); |
20 | 20 | $includepaths[] = get_include_path(); |
21 | - set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
21 | + set_include_path(implode(PATH_SEPARATOR, $includepaths)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | - public static function getContext( $site = 'unittest' ) |
|
25 | + public static function getContext($site = 'unittest') |
|
26 | 26 | { |
27 | - if( !isset( self::$context[$site] ) ) { |
|
28 | - self::$context[$site] = self::createContext( $site ); |
|
27 | + if (!isset(self::$context[$site])) { |
|
28 | + self::$context[$site] = self::createContext($site); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | return clone self::$context[$site]; |
@@ -34,58 +34,58 @@ discard block |
||
34 | 34 | |
35 | 35 | private static function getAimeos() |
36 | 36 | { |
37 | - if( !isset( self::$aimeos ) ) |
|
37 | + if (!isset(self::$aimeos)) |
|
38 | 38 | { |
39 | 39 | require_once 'Bootstrap.php'; |
40 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
40 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
41 | 41 | |
42 | - $extdir = dirname( dirname( dirname( __DIR__ ) ) ); |
|
43 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false ); |
|
42 | + $extdir = dirname(dirname(dirname(__DIR__))); |
|
43 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), false); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return self::$aimeos; |
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | - private static function createContext( $site ) |
|
50 | + private static function createContext($site) |
|
51 | 51 | { |
52 | 52 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
53 | 53 | $aimeos = self::getAimeos(); |
54 | 54 | |
55 | 55 | |
56 | - $paths = $aimeos->getConfigPaths( 'mysql' ); |
|
56 | + $paths = $aimeos->getConfigPaths('mysql'); |
|
57 | 57 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
58 | 58 | |
59 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
60 | - $ctx->setConfig( $conf ); |
|
59 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
60 | + $ctx->setConfig($conf); |
|
61 | 61 | |
62 | 62 | |
63 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
64 | - $ctx->setDatabaseManager( $dbm ); |
|
63 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
64 | + $ctx->setDatabaseManager($dbm); |
|
65 | 65 | |
66 | 66 | |
67 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
68 | - $ctx->setLogger( $logger ); |
|
67 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
68 | + $ctx->setLogger($logger); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | $cache = new \Aimeos\MW\Cache\None(); |
72 | - $ctx->setCache( $cache ); |
|
72 | + $ctx->setCache($cache); |
|
73 | 73 | |
74 | 74 | |
75 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
76 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
75 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
76 | + $ctx->setI18n(array('de' => $i18n)); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | $session = new \Aimeos\MW\Session\None(); |
80 | - $ctx->setSession( $session ); |
|
80 | + $ctx->setSession($session); |
|
81 | 81 | |
82 | 82 | |
83 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
84 | - $localeItem = $localeManager->bootstrap( $site, '', '', false ); |
|
83 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
84 | + $localeItem = $localeManager->bootstrap($site, '', '', false); |
|
85 | 85 | |
86 | - $ctx->setLocale( $localeItem ); |
|
86 | + $ctx->setLocale($localeItem); |
|
87 | 87 | |
88 | - $ctx->setEditor( 'ai-twig:unittest' ); |
|
88 | + $ctx->setEditor('ai-twig:unittest'); |
|
89 | 89 | |
90 | 90 | return $ctx; |
91 | 91 | } |
@@ -16,60 +16,60 @@ |
||
16 | 16 | |
17 | 17 | protected function setUp() |
18 | 18 | { |
19 | - if( !class_exists( '\Twig_Environment' ) ) { |
|
20 | - $this->markTestSkipped( 'Twig_Environment is not available' ); |
|
19 | + if (!class_exists('\Twig_Environment')) { |
|
20 | + $this->markTestSkipped('Twig_Environment is not available'); |
|
21 | 21 | } |
22 | 22 | |
23 | - $this->mock = $this->getMockBuilder( '\Twig_Environment' ) |
|
24 | - ->setMethods( array( 'getExtensions', 'getLoader', 'loadTemplate' ) ) |
|
23 | + $this->mock = $this->getMockBuilder('\Twig_Environment') |
|
24 | + ->setMethods(array('getExtensions', 'getLoader', 'loadTemplate')) |
|
25 | 25 | ->disableOriginalConstructor() |
26 | 26 | ->getMock(); |
27 | 27 | |
28 | - $this->object = new \Aimeos\MW\View\Engine\Twig( $this->mock ); |
|
28 | + $this->object = new \Aimeos\MW\View\Engine\Twig($this->mock); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
32 | 32 | protected function tearDown() |
33 | 33 | { |
34 | - unset( $this->object, $this->mock ); |
|
34 | + unset($this->object, $this->mock); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
38 | 38 | public function testRender() |
39 | 39 | { |
40 | - $v = new \Aimeos\MW\View\Standard( [] ); |
|
40 | + $v = new \Aimeos\MW\View\Standard([]); |
|
41 | 41 | |
42 | - $this->mock->expects( $this->once() )->method( 'getExtensions' ) |
|
43 | - ->will( $this->returnValue( array( [] ) ) ); |
|
42 | + $this->mock->expects($this->once())->method('getExtensions') |
|
43 | + ->will($this->returnValue(array([]))); |
|
44 | 44 | |
45 | 45 | |
46 | - $view = $this->getMockBuilder( '\Twig_Template' ) |
|
47 | - ->setConstructorArgs( array ( $this->mock ) ) |
|
48 | - ->setMethods( array( 'getBlockNames', 'render', 'renderBlock' ) ) |
|
46 | + $view = $this->getMockBuilder('\Twig_Template') |
|
47 | + ->setConstructorArgs(array($this->mock)) |
|
48 | + ->setMethods(array('getBlockNames', 'render', 'renderBlock')) |
|
49 | 49 | ->getMockForAbstractClass(); |
50 | 50 | |
51 | - $view->expects( $this->once() )->method( 'getBlockNames' ) |
|
52 | - ->will( $this->returnValue( array( 'testblock' ) ) ); |
|
51 | + $view->expects($this->once())->method('getBlockNames') |
|
52 | + ->will($this->returnValue(array('testblock'))); |
|
53 | 53 | |
54 | - $view->expects( $this->once() )->method( 'renderBlock' ) |
|
55 | - ->will( $this->returnValue( 'block content' ) ); |
|
54 | + $view->expects($this->once())->method('renderBlock') |
|
55 | + ->will($this->returnValue('block content')); |
|
56 | 56 | |
57 | - $view->expects( $this->once() )->method( 'render' ) |
|
58 | - ->will( $this->returnValue( 'test' ) ); |
|
57 | + $view->expects($this->once())->method('render') |
|
58 | + ->will($this->returnValue('test')); |
|
59 | 59 | |
60 | 60 | |
61 | - $loader = $this->getMockBuilder( '\Twig_LoaderInterface' ) |
|
61 | + $loader = $this->getMockBuilder('\Twig_LoaderInterface') |
|
62 | 62 | ->disableOriginalConstructor() |
63 | 63 | ->getMockForAbstractClass(); |
64 | 64 | |
65 | - $this->mock->expects( $this->once() )->method( 'getLoader' ) |
|
66 | - ->will( $this->returnValue( $loader) ); |
|
65 | + $this->mock->expects($this->once())->method('getLoader') |
|
66 | + ->will($this->returnValue($loader)); |
|
67 | 67 | |
68 | - $this->mock->expects( $this->once() )->method( 'loadTemplate' ) |
|
69 | - ->will( $this->returnValue( $view) ); |
|
68 | + $this->mock->expects($this->once())->method('loadTemplate') |
|
69 | + ->will($this->returnValue($view)); |
|
70 | 70 | |
71 | 71 | |
72 | - $result = $this->object->render( $v, __FILE__, array( 'key' => 'value' ) ); |
|
73 | - $this->assertEquals( 'test', $result ); |
|
72 | + $result = $this->object->render($v, __FILE__, array('key' => 'value')); |
|
73 | + $this->assertEquals('test', $result); |
|
74 | 74 | } |
75 | 75 | } |