1 | <?php |
||
2 | |||
3 | /** |
||
4 | * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
||
5 | * @copyright Aimeos (aimeos.org), 2014-2018 |
||
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 getContext( $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 | * @param string $site |
||
51 | */ |
||
52 | private static function createContext( $site ) |
||
53 | { |
||
54 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
||
55 | $mshop = self::getAimeos(); |
||
56 | |||
57 | |||
58 | $paths = $mshop->getConfigPaths( 'mysql' ); |
||
59 | $paths[] = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'config'; |
||
60 | |||
61 | $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
||
62 | $ctx->setConfig( $conf ); |
||
63 | |||
64 | |||
65 | $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
||
66 | $ctx->setDatabaseManager( $dbm ); |
||
67 | |||
68 | |||
69 | $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
||
70 | $ctx->setLogger( $logger ); |
||
71 | |||
72 | |||
73 | $session = new \Aimeos\MW\Session\None(); |
||
74 | $ctx->setSession( $session ); |
||
75 | |||
76 | |||
77 | $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
||
0 ignored issues
–
show
|
|||
78 | $localeItem = $localeManager->bootstrap( $site, '', '', false ); |
||
79 | |||
80 | $ctx->setLocale( $localeItem ); |
||
81 | |||
82 | $ctx->setEditor( 'ai-zend2:unittest' ); |
||
83 | |||
84 | return $ctx; |
||
85 | } |
||
86 | } |
||
87 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.