I'm having some problems with the dependency injection. Since i've updated phalcon incubator from 1.2.4 to 1.3.0, i can't run my unit tests anymore. These messages appears:
Phalcon\DI\Exception: Service 'collectionManager' was not found in the dependency injection container
or
Phalcon\DI\Exception: Service 'Mysql1' was not found in the dependency injection container
I know I have to set my collectionManager(i did), but it doens't work.
Can anyone explain me how to do it correctly?
my TestHelper.php
$config = new \Phalcon\Config(array (
'database' => array(
'mysql1' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'dbname' => 'test',
),
'mongo' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'dbname' => 'test',
)
),
));
$di->set('collectionManager', function () {
return new \Phalcon\Mvc\Collection\Manager();
}, true);
// mysql database
$di->set('Mysql1', function () use ($config) {
$conn = new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => $config->database->mysql1->host,
"username" => $config->database->mysql1->username,
"password" => $config->database->mysql1->password,
"dbname" => $config->database->mysql1->dbname,
"options" => array(
PDO::ATTR_AUTOCOMMIT => 0
)
));
return $conn;
});
//MongoDB Database
$di->set('MongoDB', function () use ($config) {
if (!$config->database->mongo->username OR !$config->database->mongo->password) {
$mongo = new MongoClient('mongodb://' . $config->database->mongo->host);
} else {
$mongo = new MongoClient("mongodb://" . $config->database->mongo->username . ":" . $config->database->mongo->password . "@" . $config->database->mongo->host, array("db" => $config->database->mongo->dbname));
}
return $mongo->selectDb($config->database->mongo->dbname);
}, TRUE);