public function addServiceToContainer($name, $definition, $shared = false)
    {
        try {
            $service = $this->di->set($name, $definition, $shared);
            return $service->resolve();
        } catch (\Exception $e) {
            $this->fail($e->getMessage());

            return null;
        }
    }
public function addServiceToContainer($name, $definition, $shared = false)
    {
        try {
            $service = $this->di->set($name, $definition, $shared);
            return $service->resolve();
        } catch (\Exception $e) {
            $this->fail($e->getMessage());

            return null;
        }
    }
public function addServiceToContainer ( $ name , $ definition , $ shared = false ) { try { $ service = $ this -> di -> set ( $ name , $ definition , $ shared ) ; return $ service -> resolve ( ) ; } catch ( \ Exception $ e ) { $ this -> fail ( $ e -> getMessage ( ) ) ; return null ; } }
Registers a service in the services container and resolve it. This record will be erased after the test.
Recommended to use for unit testing.

``` php
<?php
$filter = $I->addServiceToContainer('filter', ['className' => '\Phalcon\Filter']);
$filter = $I->addServiceToContainer('answer', function () {
return rand(0, 1) ? 'Yes' : 'No';
}, true);
?>
```

@param string $name
@param mixed $definition
@param boolean $shared
@return mixed|null
@part services
Registers a service in the services container and resolve it . This record will be erased after the test . Recommended to use for unit testing .