title: Laravel package test
body: <p>Hi everyone I'm creating a Laravel package and I'm trying to implement the tests.</p>
  
  <p>My composer.json has this structure:</p>
  
  <pre><code>"require-dev": {
      "graham-campbell/testbench": "^3.1",
      "mockery/mockery": "^0.9.4",
      "phpunit/phpunit": "^4.8|^5.0"
  },
  </code></pre>
  
  <p>I'm using <a href="https://github.com/GrahamCampbell/Laravel-TestBench" rel="nofollow">this package</a> for the test creation. I've looked at other packages of Graham Campbell in order to understand a little better how he creates the tests and I'm trying to "adapt" his classes for my goals.</p>
  
  <p>The problem is that I receive this error when running phpunit:</p>
  
  <pre><code>1) IlGala\Tests\LaravelWizzy\WizzyTest::testGetPrefix
  Mockery\Exception\NoMatchingExpectationException: No matching handler found for Mockery_0_Illuminate_Contracts_Config_Repository::get("wizzy.prefix", ""). Either the method was unexpected or its arguments matched no expected argument list for this method
  
  /home/ilgala/NetBeansProjects/laravelWizzy/packages/ilgala/laravel-wizzy/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php:93
  /home/ilgala/NetBeansProjects/laravelWizzy/packages/ilgala/laravel-wizzy/src/Wizzy.php:68
  /home/ilgala/NetBeansProjects/laravelWizzy/packages/ilgala/laravel-wizzy/tests/WizzyTest.php:71
  </code></pre>
  
  <p>I'm trying to test the Wizzy class which is registered as singleton in the WizzyServiceProvider:</p>
  
  <pre><code>$this-&gt;app-&gt;singleton('wizzy', function (Container $app) {
      $config = $app['config'];
  
      return new Wizzy($config);
  });
  </code></pre>
  
  <p>This is my test class:</p>
  
  <pre><code>protected $defaults = [
      [...]
  ];
  
  /**
   *
   */
  public function testGetPrefix()
  {
      $wizzy = $this-&gt;getWizzy();
  
      $this-&gt;assertSame('install', $wizzy-&gt;getPrefix());
  }
  
  protected function getWizzy()
  {
      $repository = Mockery::mock(Repository::class);
  
      $wizzy = new Wizzy($repository);
  
      $wizzy-&gt;getConfig()-&gt;shouldReceive('get')-&gt;once()
              -&gt;with('wizzy.prefix')-&gt;andReturn($this-&gt;defaults['prefix']);
  
      return $wizzy;
  }
  </code></pre>
  
  <p>An finally this is the Wizzy class:</p>
  
  <pre><code>/**
   * Config repository.
   *
   * @var \Illuminate\Contracts\Config\Repository
   */
  protected $config;
  
  /**
   * Creates new instance.
   */
  public function __construct(Repository $config)
  {
      $this-&gt;config = $config;
  }
  
  /**
   * Get the config instance.
   *
   * @return \Illuminate\Contracts\Config\Repository
   */
  public function getConfig()
  {
      return $this-&gt;config;
  }
  
  /**
   * Get the configuration name.
   *
   * @return string
   */
  protected function getConfigName()
  {
      return 'wizzy';
  }
  
  /**
   * Get wizzy route group prefix from the config file.
   *
   * @return string wizzy.prefix
   */
  public function getPrefix()
  {
      return $this-&gt;config-&gt;get($this-&gt;getConfigName() . '.prefix', '');
  }
  </code></pre>
  
  <p>Can anyone help me understand what am I doing wrong?</p>