title: phpunit cannot find app classes in Yii2
body: <p>Trying to set up phpunit with the Yii2 framework.  I am using Composer for managing dependencies</p>
  
  <pre><code>"require-dev": {
      "yiisoft/yii2-codeception": "*",
      "yiisoft/yii2-debug": "*",
      "yiisoft/yii2-gii": "*",
      "phpunit/phpunit": "3.7.*"
  },
  </code></pre>
  
  <p>I used Pear to install PHPUnit, following the instructions in the <a href="http://phpunit.de/manual/current/en/phpunit-book.pdf" rel="nofollow">manual</a>.  My OS is ubuntu 12.04.
  I am working with the basic app file structure:</p>
  
  <pre><code>-app 
     -tests
        -unit
           -models
              -UserTest.php
     -models
        -User.php
  </code></pre>
  
  <p>I run the UserTest from within /tests/unit/models, and I get a PHP fatal error:</p>
  
  <pre><code>PHP Fatal error:  Class 'User' not found
  PHP Stack trace:
  PHP   1. {main}() /usr/local/bin/phpunit:0
  PHP   2. PHPUnit_TextUI_Command::main() /usr/local/bin/phpunit:615
  PHP   3. PHPUnit_TextUI_Command-&gt;run()     
  phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:129
  PHP   4. PHPUnit_Runner_BaseTestRunner-&gt;getTest()    
  phar:///usr/local/bin/phpunit/phpunit/TextUI/Command.php:150
  PHP   5. PHPUnit_Runner_BaseTestRunner-&gt;loadSuiteClass() 
  phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php:104
  PHP   6. PHPUnit_Runner_StandardTestSuiteLoader-&gt;load() 
  phar:///usr/local/bin/phpunit/phpunit/Runner/BaseTestRunner.php:168
  PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() 
  phar:///usr/local/bin/phpunit/phpunit/Runner/StandardTestSuiteLoader.php:77
  PHP   8. PHPUnit_Util_Fileloader::load() 
  phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:76
  PHP   9. include_once() phar:///usr/local/bin/phpunit/phpunit/Util/Fileloader.php:92
  PHP  10. require_once() /home/thomas/Documents/records/tests/unit/models/UserTest.php:4
  </code></pre>
  
  <p>My test looks like this.  Notice that I've tried including the class directly to no avail. </p>
  
  <pre><code>&lt;?php
  
  //set_include_path(get_include_path() . PATH_SEPARATOR . getcwd/../../../);
  //require_once('models/User.php');
  //require_once('db/ActiveRecord.php');
  
  class UserTest extends PHPUnit_Framework_TestCase
  {
  
  public function testForAttributeId() {
      $this-&gt; assertClassHasAttribute('id', 'User');
  }
  public function testFindIdentity() {
      $userobj = new \app\models\User();
      $user = $userobj-&gt;findIdentity(hash('sha256', 871821997));
      $this-&gt; assertContainsOnlyInstancesOf('User', $user);
      $this-&gt; assertEquals($user-&gt;id, 871821997);
      $this-&gt; assertEquals($user-&gt;name, 'Thomas Dressler');
  }
  
  /*  
   public function testEmpty()
   {
       $stack = array();
       $this-&gt;assertEmpty($stack);
       return $stack;
   }
   /**
   * @depends testEmpty
   *
   public function testPush(array $stack)
   {
       array_push($stack, 'foo');
       $this-&gt;assertEquals('foo', $stack[count($stack)-1]);
       $this-&gt;assertNotEmpty($stack);
       return $stack;
   }
   /**
   * @depends testPush
   *
   public function testPop(array $stack)
   {
       $this-&gt;assertEquals('foo', array_pop($stack));
       $this-&gt;assertEmpty($stack);
   }*/
  }
  ?&gt;
  </code></pre>
  
  <p>I've tried upgrading Pear, re-installing PHPUnit, and checking the paths in php.ini.  My path looks like </p>
  
  <pre><code>include_path = ".:/usr/share/php:~/.composer/vendor/bin/:/usr/share/php/PHPunit:/usr/share/php/PEAR"
  </code></pre>