|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
setlocale( LC_ALL, 'en_US.UTF-8' ); |
|
4
|
|
|
|
|
5
|
|
|
// if the bundle is within a Slim project, try to reuse the project's autoload |
|
6
|
|
|
$files = array( |
|
7
|
|
|
__DIR__ . '/../vendor/autoload.php', |
|
8
|
|
|
__DIR__ . '/../../vendor/autoload.php', |
|
9
|
|
|
); |
|
10
|
|
|
|
|
11
|
|
|
$autoload = false; |
|
12
|
|
|
foreach( $files as $file ) |
|
13
|
|
|
{ |
|
14
|
|
|
if( is_file( $file ) ) { |
|
15
|
|
|
$autoload = include_once $file; |
|
16
|
|
|
break; |
|
17
|
|
|
} |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
if( !$autoload ) |
|
21
|
|
|
{ |
|
22
|
|
|
exit( |
|
23
|
|
|
"Unable to find autoload.php file, please use composer to load dependencies: |
|
24
|
|
|
wget http://getcomposer.org/composer.phar |
|
25
|
|
|
php composer.phar install |
|
26
|
|
|
Visit http://getcomposer.org/ for more information.\n" |
|
27
|
|
|
); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
|
|
31
|
|
|
class LocalWebTestCase extends \PHPUnit\Framework\TestCase |
|
32
|
|
|
{ |
|
33
|
|
|
public function call( $method, $path, $params = array(), $body = '' ) |
|
34
|
|
|
{ |
|
35
|
|
|
$app = new \Slim\App( array( |
|
36
|
|
|
'settings' => array( 'determineRouteBeforeAppMiddleware' => true ) |
|
37
|
|
|
) ); |
|
38
|
|
|
|
|
39
|
|
|
$settings = array( |
|
40
|
|
|
'disableSites' => false, |
|
41
|
|
|
'routes' => array( |
|
42
|
|
|
'admin' => '/{site}/admin', |
|
43
|
|
|
'extadm' => '/{site}/admin/extadm', |
|
44
|
|
|
'jqadm' => '/{site}/admin/jqadm', |
|
45
|
|
|
'jsonadm' => '/{site}/admin/jsonadm', |
|
46
|
|
|
'jsonapi' => '/{site}/jsonapi', |
|
47
|
|
|
'account' => '/{site}/profile', |
|
48
|
|
|
'default' => '/{site}/shop', |
|
49
|
|
|
'update' => '/{site}', |
|
50
|
|
|
), |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
$boot = new \Aimeos\Slim\Bootstrap( $app, $settings ); |
|
54
|
|
|
$boot->setup( dirname( __DIR__ ) . '/ext' ); |
|
55
|
|
|
$boot->routes( dirname( __DIR__ ) . '/src/aimeos-routes.php' ); |
|
56
|
|
|
|
|
57
|
|
|
$c = $app->getContainer(); |
|
58
|
|
|
$env = \Slim\Http\Environment::mock( array( |
|
59
|
|
|
'REQUEST_METHOD' => $method, |
|
60
|
|
|
'REQUEST_URI' => $path, |
|
61
|
|
|
'QUERY_STRING' => http_build_query( $params ) |
|
62
|
|
|
) ); |
|
63
|
|
|
$c['request'] = \Slim\Http\Request::createFromEnvironment( $env ); |
|
64
|
|
|
$c['request']->getBody()->write( $body ); |
|
65
|
|
|
$c['response'] = new \Slim\Http\Response(); |
|
66
|
|
|
|
|
67
|
|
|
$twigconf = array( 'cache' => sys_get_temp_dir() . '/aimeos-slim-twig-cache' ); |
|
68
|
|
|
$c['view'] = new \Slim\Views\Twig( dirname( __DIR__ ) . '/templates', $twigconf ); |
|
69
|
|
|
$c['view']->addExtension( new \Slim\Views\TwigExtension( $c['router'], $c['request']->getUri() ) ); |
|
70
|
|
|
|
|
71
|
|
|
return $app->run( true ); |
|
72
|
|
|
} |
|
73
|
|
|
}; |
|
74
|
|
|
|