title: How to instantiate autowired services in Symfony?
body: <p>I want to instantiate OrderAbstraction service which requires entity manager in constructor in a test case.</p>
  
  <pre><code>class OrderAbstraction
  {
      ...
  
      /**
       * @var EntityManager
       */
      private $em;
  
  public function __construct(EntityManager $em)
      {
          $this-&gt;em = $em;
          ...
      }
  }
  </code></pre>
  
  <p>I've tried to autowire OrderAbstractionTest and give a OrderAbstraction and entity manager as parameter.</p>
  
  <pre><code>class OrderAbstractionTest extends TestCase
  {
  // tried with constructor and without it
      public function testDays(){
          $order = new OrderAbstraction();
          $order-&gt;dateFrom(new \DateTime('2019-08-20 14:00'));
          $order-&gt;dateTo(new \DateTime('2019-08-28 14:00'));
  
          $days = $order-&gt;days();
          $this-&gt;assertEquals(8, $days);
      }
  }
  </code></pre>
  
  <p>my service.yaml, autowire set to true</p>
  
  <pre><code>    App\Service\OrderAbstraction\:
          resource: '../src/Service/OrderAbstraction.php'
          arguments: 
              $em: '@Doctrine\ORM\EntityManager'
  
      App\Test\OrderAbstraction\:
          resource: '../tests/OrderAbstractionTest.php'
          arguments: 
              $em : '@Doctrine\ORM\EntityManager'
  </code></pre>
  
  <p>I keep getting something like this:</p>
  
  <blockquote>
    <p>PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to
    function App\Test\OrderAbstractionTest::__construct(), 0 passed in
    /var/www/html/autocom/bin/.phpunit/phpunit-6.5/src/Framework/TestSuite.php
    on line 476 and exactly 1 expected in
    /var/www/html/autocom/tests/OrderAbstractionTest.php:13</p>
  </blockquote>
  
  <p>Would be great to know how to instantiate services like OrderAbstraction to other services, tests. Because most of the I do something like this in controllers:</p>
  
  <pre><code>$order = new OrderAbstraction($this-&gt;em);
  </code></pre>