title: Unit Testing with a singleton inside a validation method in Laravel
body: <p>I have registered a singleton in a Service Provider (which uses a Guzzle Client in it's constructor):</p>
  
  <pre><code>public function register()
  {
      $this-&gt;app-&gt;singleton(Channel::class, function ($app) {
          return new ChannelClient(new Client([
              'http_errors'=&gt; false,
              'timeout' =&gt; 10,
              'connect_timeout' =&gt; 10
          ]));
      });
  }
  </code></pre>
  
  <p>I have a validation method:</p>
  
  <pre><code> public static function validateChannel($attribute, $value, $parameters, \Illuminate\Validation\Validator $validator)
      {
          $dataloader = app()-&gt;make(\App\Client\Channel::class);
          if($dataloader-&gt;search($value)){
              return true;
          }
      }
  </code></pre>
  
  <p>In the PHPUnit Test, how can I replace the <code>app()-&gt;make(\App\Client\Channel::class);</code> with a mocked <code>Client</code> class but still test the validation function within the test?</p>