title: How to append fixtures in liip functional test (symfony 2.8)?
body: <p>I would like to append fixtures in my functional test (based on  <a href="https://github.com/liip/LiipFunctionalTestBundle" rel="nofollow noreferrer">LiipFunctionalTestBundle</a> in symfony 2.8. Even it is a dev database I working on, I do still need to append the fixtures since I will have:</p>
  
  <ul>
  <li>regional data (country, region, county)</li>
  <li>vehicule brands and models</li>
  <li>...</li>
  </ul>
  
  <p>Consequently, having the DB purged after each functional test will not be nice for me.</p>
  
  <p><strong>NOTICE:</strong> Appending fixtures (without purging) through command line is working with success: <code>php app/console doctrine:fixtures:load --append</code></p>
  
  <p>So, below is my functional test:</p>
  
  <pre><code>&lt;?php
  
  namespace Minn\APIBundle\Tests\Controller;
  
  use Liip\FunctionalTestBundle\Test\WebTestCase as WebTestCase;
  //use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as WebTestCase;
  use Minn\APIBundle\Tests\Fixtures\Entity\LoadBrandData;
  use Doctrine\Common\DataFixtures\Purger\ORMPurger;
  
  class BrandControllerTest extends WebTestCase {
  
      public function setUp() {
          $this-&gt;auth = array(
              'PHP_AUTH_USER' =&gt; 'restapi',
              'PHP_AUTH_PW' =&gt; 'secretpw',
          );
  
          $this-&gt;client = static::createClient(array(), $this-&gt;auth);
      }
  
      public function testJsonGetPageAction() {
          $fixtures = array('Minn\APIBundle\Tests\Fixtures\Entity\LoadBrandData');
          $this-&gt;loadFixtures($fixtures);
          $brands = LoadBrandData::$brands;
          $brand = array_pop($brands);
  
          $route = $this-&gt;getUrl('api_1_brand_get_brand', array('id' =&gt; $brand-&gt;getId(), '_format' =&gt; 'json'));
  
          $this-&gt;client-&gt;request('GET', $route, array('ACCEPT' =&gt; 'application/json'));
          $response = $this-&gt;client-&gt;getResponse();
          $this-&gt;assertJsonResponse($response, 200);
          $content = $response-&gt;getContent();
  
          $decoded = json_decode($content, true);
          $this-&gt;assertTrue(isset($decoded['id']));
      }
  
      // ..
  }
  </code></pre>
  
  <p>This test purges the DB. So, I tried the code proposed in <a href="https://stackoverflow.com/questions/14752930/best-way-to-create-a-test-database-and-load-fixtures-on-symfony-2-webtestcase?rq=1">link</a> by doing this change:</p>
  
  <pre><code>// removed code
  $fixtures = array('Minn\APIBundle\Tests\Fixtures\Entity\LoadBrandData');
  $this-&gt;loadFixtures($fixtures);
  
  // new code
  $this-&gt;runCommand('doctrine:fixtures:load --append --no-interaction --fixtures=src/Minn/APIBundle/Tests/Fixtures/Entity/LoadBrandData.php');
  </code></pre>
  
  <p>But, functional test doest not work.</p>
  
  <pre><code>There was 1 error:
  
  1) Minn\APIBundle\Tests\Controller\BrandControllerTest::testJsonGetPageAction
  Error: Call to a member function getId() on null
  
  /home/amine/NetBeansProjects/minnapi/src/Minn/APIBundle/Tests/Controller/BrandControllerTest.php:27
  </code></pre>
  
  <p>I tried to used options available in the function <em>loadFixtures()</em> by doing this change:</p>
  
  <pre><code>// removed code:
  $fixtures = array('Minn\APIBundle\Tests\Fixtures\Entity\LoadBrandData');
  $this-&gt;loadFixtures($fixtures);
  
  // new code 
  $fixtures = array('Minn\APIBundle\Tests\Fixtures\Entity\LoadBrandData');
  $this-&gt;loadFixtures($fixtures, null,'doctrine', ORMPurger::PURGE_MODE_DELETE);
  </code></pre>
  
  <p>Verdict: DB is always purged after each run of the functional test.</p>
  
  <p>So, any suggestions??</p>
  
  <p>Thanks,</p>
  
  <p><strong>NB:</strong> bundles versions described in composer.json</p>
  
  <pre><code>    "doctrine/doctrine-fixtures-bundle": "dev-master",
      "phpunit/phpunit": "5.4.*",
      "liip/functional-test-bundle":"1.6.*",
      "guzzle/guzzle": "v3.9.*"
  </code></pre>