1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
6
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
7
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
8
|
|
|
*/ |
9
|
|
|
class TestHelperJobs |
10
|
|
|
{ |
11
|
|
|
private static $aimeos; |
12
|
|
|
private static $context; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
public static function bootstrap() |
16
|
|
|
{ |
17
|
|
|
self::getAimeos(); |
18
|
|
|
\Aimeos\MShop::cache( false ); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
public static function getContext( $site = 'unittest' ) |
23
|
|
|
{ |
24
|
|
|
if( !isset( self::$context[$site] ) ) { |
25
|
|
|
self::$context[$site] = self::createContext( $site ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
return clone self::$context[$site]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
|
32
|
|
|
public static function getAimeos() |
33
|
|
|
{ |
34
|
|
|
if( !isset( self::$aimeos ) ) |
35
|
|
|
{ |
36
|
|
|
require_once 'Bootstrap.php'; |
37
|
|
|
spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
38
|
|
|
|
39
|
|
|
$extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
40
|
|
|
self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
return self::$aimeos; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public static function getControllerPaths() |
48
|
|
|
{ |
49
|
|
|
return self::getAimeos()->getCustomPaths( 'controller/jobs' ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param string $site |
55
|
|
|
*/ |
56
|
|
|
private static function createContext( $site ) |
57
|
|
|
{ |
58
|
|
|
$ctx = new \Aimeos\MShop\Context\Item\Standard(); |
59
|
|
|
$aimeos = self::getAimeos(); |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
$paths = $aimeos->getConfigPaths(); |
63
|
|
|
$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
64
|
|
|
$file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
65
|
|
|
|
66
|
|
|
$conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
67
|
|
|
$conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
68
|
|
|
$conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
69
|
|
|
$ctx->setConfig( $conf ); |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
73
|
|
|
$ctx->setLogger( $logger ); |
74
|
|
|
|
75
|
|
|
|
76
|
|
|
$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
77
|
|
|
$ctx->setDatabaseManager( $dbm ); |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
$fs = new \Aimeos\MW\Filesystem\Manager\Standard( $conf ); |
81
|
|
|
$ctx->setFilesystemManager( $fs ); |
82
|
|
|
|
83
|
|
|
|
84
|
|
|
$mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
85
|
|
|
$ctx->setMessageQueueManager( $mq ); |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
$cache = new \Aimeos\MW\Cache\None(); |
89
|
|
|
$ctx->setCache( $cache ); |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
$session = new \Aimeos\MW\Session\None(); |
93
|
|
|
$ctx->setSession( $session ); |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
$i18n = new \Aimeos\MW\Translation\None( 'de' ); |
97
|
|
|
$ctx->setI18n( array( 'de' => $i18n ) ); |
98
|
|
|
|
99
|
|
|
|
100
|
|
|
$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
101
|
|
|
$locale = $localeManager->bootstrap( $site, 'de', '', false ); |
102
|
|
|
$ctx->setLocale( $locale ); |
103
|
|
|
|
104
|
|
|
|
105
|
|
|
$view = self::createView( $conf ); |
106
|
|
|
$ctx->setView( $view ); |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
$ctx->setEditor( 'core:controller/jobs' ); |
110
|
|
|
|
111
|
|
|
return $ctx; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
protected static function createView( \Aimeos\MW\Config\Iface $config ) |
116
|
|
|
{ |
117
|
|
|
$tmplpaths = array_merge_recursive( |
118
|
|
|
self::getAimeos()->getCustomPaths( 'client/html/templates' ), |
119
|
|
|
self::getAimeos()->getCustomPaths( 'controller/jobs/templates' ) |
120
|
|
|
); |
121
|
|
|
|
122
|
|
|
$view = new \Aimeos\MW\View\Standard( $tmplpaths ); |
123
|
|
|
|
124
|
|
|
$trans = new \Aimeos\MW\Translation\None( 'de_DE' ); |
125
|
|
|
$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
126
|
|
|
$view->addHelper( 'translate', $helper ); |
127
|
|
|
|
128
|
|
|
$helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'http://baseurl' ); |
129
|
|
|
$view->addHelper( 'url', $helper ); |
130
|
|
|
|
131
|
|
|
$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
132
|
|
|
$view->addHelper( 'number', $helper ); |
133
|
|
|
|
134
|
|
|
$helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
135
|
|
|
$view->addHelper( 'date', $helper ); |
136
|
|
|
|
137
|
|
|
$config = new \Aimeos\MW\Config\Decorator\Protect( $config, array( 'controller/jobs', 'client/html' ) ); |
138
|
|
|
$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
139
|
|
|
$view->addHelper( 'config', $helper ); |
140
|
|
|
|
141
|
|
|
return $view; |
142
|
|
|
} |
143
|
|
|
} |
144
|
|
|
|