phpspec/Symfony2Extension — pull request #3 by docteurklein (2013-09-13 15:40:08+00:00)
Title: [Technical] Should we provide a Container that extends BaseContainer or a mock of it ?

I'm currently implementing a Maintainer for BaseController that creates preconfigured collaborators.

For example, in a spec:

``` php

setContainer($container); // should be avoided
$this->generateUrl('homepage')->shouldReturn('test');
}
}

```

This works already. (PR to come).

As you can see, the container is preconfigured to return a `RouterInterface` instance for `$this->container->get('router')` call.
Same for common services like `request`, `session`, ...

This would superseed the ContainerInjecterMaintainer + the ContainerInitailizerMaintainer.

I also consider the method I describe a bit cleaner, for the following points:

#### pros

- no `$this->container` property in the spec. (if we start to do that, we'll soon have dozen of spec properties)
- no [extended Container](https://github.com/phpspec/Symfony2Extension/blob/master/src/PhpSpec/Symfony2Extension/Specification/Container.php)
- common services classes and names are configurable via DIC
- you can override them per spec method (docblock or typehint)

### cons (if any):

- you have to follow naming conventions to access common services

I'd be curious to have your opinions on this @everzet @jakzal @MarcelloDuarte .