title: How should we write test for repository , logic and controller layer in laravel?
body: <p>I am trying to write test for repository, logic and controller layer. Repository class injected inside logic and logic class injected to controller. I wrote the test for repository and mock repository in logic class to write test for logic. But for controller i wrote integration test like this:</p>
  <pre><code>public function test_create_role()
  {
      $data = Role::factory()-&gt;make()-&gt;toArray();
  
      $this-&gt;postJson(route('roles.store'), $data)
          -&gt;assertCreated();
  }
  </code></pre>
  <p>Do I need to check if new data has been added to data base like this:</p>
  <pre><code>public function test_create_role()
  {
      $data = Role::factory()-&gt;make()-&gt;toArray();
  
      $this-&gt;postJson(route('roles.store'), $data)
          -&gt;assertCreated();
  
      $this-&gt;assertDatabaseHas('roles', $data);
  }
  </code></pre>
  <p>Or is the repository test enough?
  Do we need to test the repository layer and logic layer separately, or is integration testing enough?</p>