title: PHPUnit issue asserting mock is a ReflectionProperty object using Laravel
body: <p>I am new to PHPUnit and am trying to set up my first test. It is failing with the following error message</p>
  
  <blockquote>
    <p>Failed asserting that ReflectionProperty Object (...) is an instance of class "Illuminate\Database\Eloquent\Model".  </p>
  </blockquote>
  
  <p>Essentially, I am trying to mock the creation of a model which I am injecting into a constructor and testing it is the right type through reflection. I am following the advice laid out in this post/answer:</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/31893619/how-do-i-test-this-class-using-phpunit">How do I test this class using phpunit?</a></p>
  </blockquote>
  
  <p>If anyone can give me some guidance, that would greatly appreciated.</p>
  
  <p>The class being tested is here:</p>
  
  <pre><code>&lt;?php
  
  namespace PlaneSaleing\Repo\Listing;
  
  use Illuminate\Database\Eloquent\Model;
  
  class EloquentListing implements ListingInterface {
  
      protected $advert;
  
      public function __construct(Model $advert)
      {
          $this-&gt;advert = $advert;
      }
  
      /**
       * Get paginated listings
       *
       * @param int  Current page
       * @param int Number of listings per page
       * @return StdClass object with $items and $totalItems for pagination
       */
      public function byPage($page=1, $limit=10)
      {
  
          $result = new \StdClass;
          $result-&gt;page = $page;
          $result-&gt;limit = $limit;
          $result-&gt;totalItems = 0;
          $result-&gt;items = array();
  
          $listings = $this-&gt;advert
                           -&gt;orderBy('created_at')
                           -&gt;skip( $limit * ($page-1) )
                           -&gt;take($limit)
                           -&gt;get();
  
          // Create object to return data useful for pagination
          $result-&gt;items = $listings-&gt;all();
          $result-&gt;totalItems = $this-&gt;totalListings();
  
          return $result;
  
      }
  </code></pre>
  
  <p>The service provider is here:</p>
  
  <pre><code>&lt;?php
  
  namespace PlaneSaleing\Repo;
  
  use Illuminate\Support\ServiceProvider;
  use PlaneSaleing\Repo\Listing\EloquentListing as Listing;
  use \Advert;
  
  class RepoServiceProvider extends ServiceProvider {
  
      public function register()
      {
  
        $this-&gt;app-&gt;bind('PlaneSaleing\Repo\Listing\ListingInterface', function($app) {
          $app-&gt;make(Listing(new Advert));
        } );
  
      }
  
  }
  </code></pre>
  
  <p>My Test is here:</p>
  
  <pre><code>&lt;?php
  
  use \Mockery;
  use \ReflectionClass;
  use PlaneSaleing\Repo\Listing\EloquentListing;
  
  class EloquentListingTest extends \TestCase
  {
  
      /**
       * Testing if __constructor is setting up property
       */
      public function testModelSetsUp()
      {
          $mock1 = Mockery::mock(Illuminate\Database\Eloquent\Model::class);
  
          $listing = new EloquentListing($mock1);
  
          $reflection = new ReflectionClass($listing);
  
          // Making your attribute accessible
          $property1 = $reflection-&gt;getProperty('advert');
          $property1-&gt;setAccessible(true);
  
          $this-&gt;assertInstanceOf(Illuminate\Database\Eloquent\Model::class, $property1);
      }
  </code></pre>