title: Symfony2 access private services in tests
body: <p>Currently I'm working on testing some services in Symfony2 and I'm trying to use Guzzle MockPlugin for controlling CURL responses. Symfony version 2.3.8 is used. I've got to an interesting behaviour and I'm not sure if this is a Symfony2 bug or not.</p>
  
  <p>I have these services in services.yml:</p>
  
  <pre><code>lookup_service_client:
      class: FOO
      public: false
      factory_service: lookup_client_builder
      factory_method: build
  
  lookup_repository_auth_type:
      class: AuthType
      arguments: ["@lookup_service_client"]
  
  lookup_repository_cancel_reason:
      class: CancelReason
      arguments: ["@lookup_service_client"]
  
  payment_service_client:
      class: FOO
      public: false
      factory_service: payment_client_builder
      factory_method: build
  
  payment_repository:
      class: Payment
      arguments: ["@payment_service_client"]
  </code></pre>
  
  <p>The name of the classes are not important. You can see that both "lookup_service_client" and "lookup_service_client" are PRIVATE services.</p>
  
  <p>I have a test class, which extends Symfony\Bundle\FrameworkBundle\Test\WebTestCase. In one test I need to do something like:</p>
  
  <pre><code>$lookup = $this-&gt;client-&gt;getContainer()-&gt;get('lookup_service_client');
  
  $payment = $this-&gt;client-&gt;getContainer()-&gt;get('payment_service_client');
  </code></pre>
  
  <p>I expected that, setting those services as PRIVATE, will not let me retrieve the services from container in tests, but the actual result is:</p>
  
  <pre><code>$lookup = $this-&gt;client-&gt;getContainer()-&gt;get('lookup_service_client'); =&gt; returns the service instance
  
  $payment = $this-&gt;client-&gt;getContainer()-&gt;get('payment_service_client'); =&gt; returns an exception saying: "You have requested a non-existent service"
  </code></pre>
  
  <p>The only difference between those tow service_client services is that "lookup_service_client" is injected in several other services, while "payment_service_client" is injected in only one other service. </p>
  
  <p>So, the questions are:</p>
  
  <ol>
  <li><p>Why I can retrieve from container "lookup_service_client", since I've set it to private?</p></li>
  <li><p>Why I can retrieve "lookup_service_client", but cannot retrieve "payment_service_client" since the only difference is presented above?</p></li>
  <li><p>Is it a Symfony2 bug that I can access private service?</p></li>
  </ol>