Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pimple/pimple (v1.1.1 => v3.3.0) #313

Merged
merged 1 commit into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"slim/slim": "^2.6.3",
"slim/views": "^0.1.0",
"twig/twig": "~1.17",
"pimple/pimple": "^1.0.2",
"pimple/pimple": "^3.3",
"perftools/xhgui-collector": "^1.7.0"
},
"require-dev": {
Expand Down
21 changes: 13 additions & 8 deletions src/Xhgui/ServiceContainer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<?php

use Pimple\Container;
use Slim\Slim;
use Slim\Views\Twig;
use Slim\Middleware\SessionCookie;

class Xhgui_ServiceContainer extends Pimple
class Xhgui_ServiceContainer extends Container
{
/** @var self */
protected static $_instance;

/**
* @return self
*/
public static function instance()
{
if (empty(static::$_instance)) {
Expand Down Expand Up @@ -43,7 +49,7 @@ protected function _slimApp()
return $view;
};

$this['app'] = $this->share(static function ($c) {
$this['app'] = static function ($c) {
if ($c['config']['timezone']) {
date_default_timezone_set($c['config']['timezone']);
}
Expand All @@ -65,7 +71,7 @@ protected function _slimApp()
$app->view($view);

return $app;
});
};
}

/**
Expand All @@ -75,7 +81,7 @@ protected function _services()
{
$this['config'] = Xhgui_Config::all();

$this['db'] = $this->share(static function ($c) {
$this['db'] = static function ($c) {
$config = $c['config'];
if (empty($config['db.options'])) {
$config['db.options'] = [];
Expand All @@ -87,15 +93,15 @@ protected function _services()
$mongo->{$config['db.db']}->results->findOne();

return $mongo->{$config['db.db']};
});
};

$this['pdo'] = $this->share(static function ($c) {
$this['pdo'] = static function ($c) {
return new PDO(
$c['config']['pdo']['dsn'],
$c['config']['pdo']['user'],
$c['config']['pdo']['pass']
);
});
};

$this['searcher.mongo'] = static function ($c) {
return new Xhgui_Searcher_Mongo($c['db']);
Expand Down Expand Up @@ -159,5 +165,4 @@ protected function _controllers()
return new Xhgui_Controller_Metrics($c['app'], $c['searcher']);
};
}

}
6 changes: 1 addition & 5 deletions tests/Controller/ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ public function setUp()
]);

$di = Xhgui_ServiceContainer::instance();
$mock = $this->getMockBuilder(Slim::class)
$di['app'] = $this->getMockBuilder(Slim::class)
->setMethods(['redirect', 'render', 'urlFor'])
->setConstructorArgs([$di['config']])
->getMock();

$di['app'] = $di->share(static function ($c) use ($mock) {
return $mock;
});
$this->import = $di['importController'];

$this->profiles = $di['searcher'];
$this->profiles->truncate();
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Controller/RunTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,11 @@ public function setUp()
]);

$di = Xhgui_ServiceContainer::instance();
$mock = $this->getMockBuilder(Slim::class)
$di['app'] = $this->getMockBuilder(Slim::class)
->setMethods(['redirect', 'render', 'urlFor'])
->setConstructorArgs([$di['config']])
->getMock();

$di['app'] = $di->share(static function ($c) use ($mock) {
return $mock;
});
$this->import = $di['importController'];
$this->runs = $di['runController'];
$this->app = $di['app'];
Expand Down
9 changes: 3 additions & 6 deletions tests/Controller/WatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ public function setUp()
'SCRIPT_NAME' => 'index.php',
'PATH_INFO' => '/watch'
]);
$di = Xhgui_ServiceContainer::instance();
unset($di['app']);

$mock = $this->getMockBuilder(Slim::class)
$di = Xhgui_ServiceContainer::instance();
$di['app'] = $this->getMockBuilder(Slim::class)
->setMethods(['redirect', 'render', 'urlFor'])
->setConstructorArgs([$di['config']])
->getMock();
$di['app'] = $di->share(static function ($c) use ($mock) {
return $mock;
});

$this->watches = $di['watchController'];
$this->app = $di['app'];
$this->searcher = $di['searcher'];
Expand Down