title: cakephp3 test component Call to a member function on() on a non-object
body: <p>I'm trying to test my plugin component written for cakephp 3.</p>
  
  <p>This is my component:</p>
  
  <pre><code>namespace CurrencyConverter\Controller\Component;
  
  use Cake\Controller\Component;
  use Cake\Datasource\ConnectionManager;
  use Cake\ORM\TableRegistry;
  
  class CurrencyConverterComponent extends Component
  {
      public $controller = null;
  
      public function setController($controller)
      {
          $this-&gt;controller = $controller;
      }
  
      public function startup($event)
      {
          $this-&gt;setController($event-&gt;subject());
      }
  
  
      public function convert($fromCurrency, $toCurrency, $amount, $saveIntoDb = 1, $hourDifference = 1, $dataSource = 'default') {
  
      }
  }
  </code></pre>
  
  <p>and this is mt test:</p>
  
  <pre><code>namespace App\Test\TestCase\Controller\Component;
  
  use CurrencyConverter\Controller\Component\CurrencyConverterComponent;
  use Cake\Controller\Controller;
  use Cake\Controller\ComponentRegistry;
  use Cake\Network\Request;
  use Cake\Network\Response;
  use Cake\TestSuite\TestCase;
  
  class CurrencyConverterComponentTest extends TestCase {
      public $fixtures = ['app.currencyconverter'];
      public $CurrencyConverter = null;
      public $controller = null;
  
      public function setUp() {
          parent::setUp();
          // Setup our component and fake test controller
          $request = new Request();
          $response = new Response();
          $this-&gt;controller = $this-&gt;getMock(
              'Cake\Controller\Controller',
              [],
              [$request, $response]
          );
          $registry = new ComponentRegistry($this-&gt;controller);
          $this-&gt;CurrencyConverter = new CurrencyConverterComponent($registry);
      }
  
      public function testAmountWithComma() {
          $fromCurrency   = 'EUR';
          $toCurrency     = 'GBP';
          $amount         = '20,00';
          $saveIntoDb     = 0;
          $hourDifference = 0;
          $dataSource     = 'test';
  
          $result = $this-&gt;CurrencyConverter-&gt;convert($fromCurrency, $toCurrency, $amount, $saveIntoDb, $hourDifference, $dataSource);
  
          $this-&gt;assertGreaterThan($result, $amount);
      }
  }
  </code></pre>
  
  <p>When I run tests I get this error in the core!!</p>
  
  <pre><code>Fatal error:  Call to a member function on() on a non-object in /Users/alessandrominoccheri/Sites/cakephp3/vendor/cakephp/cakephp/src/Controller/Controller.php on line 289
  </code></pre>
  
  <p>How can I solve this?</p>
  
  <p>Thanks</p>