|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2013 |
|
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
class TestHelper |
|
10
|
|
|
{ |
|
11
|
|
|
private static $aimeos; |
|
12
|
|
|
private static $context = []; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
public static function bootstrap() |
|
16
|
|
|
{ |
|
17
|
|
|
$mshop = self::getAimeos(); |
|
18
|
|
|
|
|
19
|
|
|
$includepaths = $mshop->getIncludePaths(); |
|
20
|
|
|
$includepaths[] = get_include_path(); |
|
21
|
|
|
set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
public static function getContext( $site = 'unittest' ) |
|
26
|
|
|
{ |
|
27
|
|
|
if( !isset( self::$context[$site] ) ) { |
|
28
|
|
|
self::$context[$site] = self::createContext( $site ); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
return clone self::$context[$site]; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
private static function getAimeos() |
|
36
|
|
|
{ |
|
37
|
|
|
if( !isset( self::$aimeos ) ) |
|
38
|
|
|
{ |
|
39
|
|
|
require_once 'Bootstrap.php'; |
|
40
|
|
|
spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
41
|
|
|
|
|
42
|
|
|
$extdir = dirname( dirname( dirname( __DIR__ ) ) ); |
|
43
|
|
|
self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false ); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return self::$aimeos; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Creates a new context item. |
|
52
|
|
|
* |
|
53
|
|
|
* @param string $site Unique site code |
|
54
|
|
|
* @return \\Aimeos\MShop\Context\Item\Iface Context object |
|
|
|
|
|
|
55
|
|
|
*/ |
|
56
|
|
|
private static function createContext( $site ) |
|
57
|
|
|
{ |
|
58
|
|
|
$ctx = new \Aimeos\MShop\Context\Item\Standard(); |
|
59
|
|
|
$mshop = self::getAimeos(); |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
$paths = $mshop->getConfigPaths( 'mysql' ); |
|
63
|
|
|
$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
|
64
|
|
|
|
|
65
|
|
|
$conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
66
|
|
|
$ctx->setConfig( $conf ); |
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
70
|
|
|
$ctx->setDatabaseManager( $dbm ); |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
74
|
|
|
$ctx->setLogger( $logger ); |
|
75
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
$session = new \Aimeos\MW\Session\None(); |
|
78
|
|
|
$ctx->setSession( $session ); |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
|
|
|
|
|
82
|
|
|
$localeItem = $localeManager->bootstrap( $site, '', '', false ); |
|
83
|
|
|
|
|
84
|
|
|
$ctx->setLocale( $localeItem ); |
|
85
|
|
|
|
|
86
|
|
|
$ctx->setEditor( 'zend:unittest' ); |
|
87
|
|
|
|
|
88
|
|
|
return $ctx; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths