title: Laravel testing redirect from function
body: <p>If I have a function that checks to see if a string is numeric and redirects back if it is not but does nothing if it is ie</p>
  <pre><code>function check_numeric(string $param) {
      if(!is_numeric($param)) {
          return Redirect::back()-&gt;with('Failed', 'Number!');
      }
  }
  </code></pre>
  <p>How would I test this in PHPUnit? I have tried to use <code>assertRedirect</code> but I am not sure of how to implement it (if it is even possible)</p>
  <p>To be clear. The <code>check_numeric()</code> function is a standalone function that is imported into controllers to be used by the different controller classes. The fucntion itself does not have a class nor a route.</p>
  <p>What I would like to do is test the function directly without its use in a  controller or route.</p>
  <p>I can test the <code>pass</code> cases by doing:</p>
  <pre><code>$this-&gt;assertNull(check_numeric('1')); // does what I want!!
  </code></pre>
  <p>However I would also like to directly check the <code>fail</code> cases with something like</p>
  <pre><code>$previousUrl = '/';
  
  $this-&gt;from($previousUrl)-&gt;(check_numeric('five'))-&gt;assertRedirect($previousUrl);
  </code></pre>