title: Does phpunit use a different php.ini file than the one configured in MAMP?
body: <p>I'm trying to run some functional tests using phpunit in Symfony2.
  When I run my test, I get this error: </p>
  
  <pre><code>PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)
  </code></pre>
  
  <p>I'm assuming phpunit cannot find my mysql socket, though I have set it in my php.ini file (in MAMP.) My web application works fine in my browser and succeeds in connecting to the database.</p>
  
  <p>I've tried adding this setting to my phpunit.xml.dist file but I get the same result:</p>
  
  <pre><code>&lt;php&gt;
      &lt;ini name="mysql.default_socket" value="/Applications/MAMP/tmp/mysql/mysql.sock"/&gt;
      &lt;!--&lt;server name="KERNEL_DIR" value="/path/to/your/app/" /&gt;--&gt;
  &lt;/php&gt;
  </code></pre>
  
  <p>Is there any way to verify/ change the php.ini file that phpunit is using?  </p>
  
  <p>If that's not the problem, then let's go back to square one. Here's the test I ran:</p>
  
  <pre><code>class VBMTest extends WebTestCase
  {
  var $container;
  
  public function setUp()
  {
       $client = static::createClient();
       $client-&gt;getKernel()-&gt;boot();
       $this-&gt;container =  $client-&gt;getContainer();
  }
  
  public function testNameNotFound() 
  {
      $form = array('lastname'=&gt;'Jones','sex'=&gt;'F','day'=&gt;'5','month'=&gt;'5','year'=&gt;'2005');
      $vbm = $this-&gt;container-&gt;get('tk.vbm');
      $vbm-&gt;init($form, 'process_app');
      $step = $vbm-&gt;getStep();
  
      $this-&gt;assertEquals(
          'register',
          $step
      );
  }
  }
  </code></pre>
  
  <p>I added this line, in case the testing app wasn't loading all of my parameters.  (I'm new to testing in Symfony2.)</p>
  
  <pre><code> $client-&gt;getKernel()-&gt;boot();
  </code></pre>
  
  <p>config_test.yml imports config_dev.yml, so I don't see why my database settings would not be included in my testing configuration.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I tried uninstalling phpunit and reinstalling it using Composer as mentioned here~ <a href="https://stackoverflow.com/questions/15716993/installing-phpunit-on-mamp-2-1-3-mountain-lion">Installing PHPUnit on MAMP 2.1.3 (Mountain Lion)</a>.</p>
  
  <p>So now I run my phpunit command with bin/phpunit.</p>
  
  <p>Still -no change in the outcome.  I still receive the "PDO::__construct(): [2002] No such file or directory" error.</p>
  
  <p><strong>UPDATE II</strong></p>
  
  <p>As I mentioned below  - responding to @Udan's suggestion - I changed the config settings in my config_test.yml file to change the host to 127.0.0.1:</p>
  
  <pre><code>doctrine:
      dbal:
          driver:   pdo_mysql
          host:     127.0.0.1
          port:     3306
          dbname:   test_tk
          user:     test_tk
          password: ############
          charset:  UTF8
  </code></pre>
  
  <p>I even added a new user and a new database for testing (test_tk).  The error changed, but I still can't test my application.</p>
  
  <pre><code>ERROR 1045 (28000): Access denied for user 'test_tk'@'localhost' (using password: YES)
  </code></pre>
  
  <p>Here's a synopsis of my user's privileges from phpmyadmin:</p>
  
  <pre><code>User:        test_tk
  Host:        %
  Type:        global
  Privileges:  All Privileges
  Grant:       Yes
  </code></pre>
  
  <p>There is something screwy going on with my mysql installation.  I used to be able to connect to mysql through the command line. And now I cannot.  Strangely - the web app still connects just fine through a web browser.</p>
  
  <p>Which brings me back to the heart of the original question.  Why does my application successfully connect to the database through a web browser, but not through phpunit?</p>
  
  <p>Any other helpful hints out there?</p>