Passed
Push — master ( 260818...ddf6f5 )
by Aimeos
17:28 queued 10:11
created

TestHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 6
eloc 33
dl 0
loc 80
rs 10
c 6
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A bootstrap() 0 7 1
A createContext() 0 33 1
A getAimeos() 0 12 2
A context() 0 7 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2014-2023
6
 */
7
8
class TestHelper
9
{
10
	private static $aimeos;
11
	private static $context = [];
12
13
14
	public static function bootstrap()
15
	{
16
		$mshop = self::getAimeos();
17
18
		$includepaths = $mshop->getIncludePaths();
19
		$includepaths[] = get_include_path();
20
		set_include_path( implode( PATH_SEPARATOR, $includepaths ) );
21
	}
22
23
24
	public static function context( $site = 'unittest' )
25
	{
26
		if( !isset( self::$context[$site] ) ) {
27
			self::$context[$site] = self::createContext( $site );
28
		}
29
30
		return clone self::$context[$site];
31
	}
32
33
34
	private static function getAimeos()
35
	{
36
		if( !isset( self::$aimeos ) )
37
		{
38
			require_once 'Bootstrap.php';
39
			spl_autoload_register( 'Aimeos\\Bootstrap::autoload' );
40
41
			$extdir = dirname( dirname( dirname( __DIR__ ) ) );
42
			self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), false );
43
		}
44
45
		return self::$aimeos;
46
	}
47
48
49
	/**
50
	 * Creates a new context item.
51
	 *
52
	 * @param string $site Unique site code
53
	 * @return \\Aimeos\MShop\Context\Item\Iface Context object
0 ignored issues
show
Bug introduced by
The type \Aimeos\MShop\Context\Item\Iface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
54
	 */
55
		private static function createContext( $site )
56
	{
57
		$ctx = new \Aimeos\MShop\Context\Item\Standard();
0 ignored issues
show
Bug introduced by
The type Aimeos\MShop\Context\Item\Standard was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
58
		$mshop = self::getAimeos();
59
60
61
		$paths = $mshop->getConfigPaths( 'mysql' );
62
		$paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config';
63
64
		$conf = new \Aimeos\MW\Config\PHPArray( [], $paths );
0 ignored issues
show
Bug introduced by
The type Aimeos\MW\Config\PHPArray was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
		$ctx->setConfig( $conf );
66
67
68
		$dbm = new \Aimeos\MW\DB\Manager\PDO( $conf );
0 ignored issues
show
Bug introduced by
The type Aimeos\MW\DB\Manager\PDO was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
69
		$ctx->setDatabaseManager( $dbm );
70
71
72
		$logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG );
0 ignored issues
show
Bug introduced by
The type Aimeos\MW\Logger\File was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The type Aimeos\MW\Logger\Base was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
73
		$ctx->setLogger( $logger );
74
75
76
		$session = new \Aimeos\MW\Session\None();
0 ignored issues
show
Bug introduced by
The type Aimeos\MW\Session\None was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
77
		$ctx->setSession( $session );
78
79
80
		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx );
0 ignored issues
show
Bug introduced by
The type Aimeos\MShop\Locale\Manager\Factory was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
81
		$localeItem = $localeManager->bootstrap( $site, '', '', false );
82
83
		$ctx->setLocale( $localeItem );
84
85
		$ctx->setEditor( 'ai-symfony:lib/custom' );
86
87
		return $ctx;
88
	}
89
}
90