Using Crypt with Laravel phpunit tests
<p>I am using phpunit with Laravel to perform some tests. I have a lot of database data that is encrypted. </p>

<p>In one of my tests I fill out a form, and once it is completed, the data is encrypted using <code>Crypt::encrypt('data from field goes here')</code>.</p>

<p>Here is the code: </p>

<pre><code>$this-&gt;visit('/requests/create')
             -&gt;seePageIs('/requests/create')
             -&gt;type('FirstNameTest1', 'first_name')
             -&gt;press('Create Request')
             -&gt;see('The request has been created.');

// Fails here
$this-&gt;seeInDatabase('requests', ['first_name' =&gt; Crypt::encrypt('FirstNameTest1')]);
</code></pre>

<p>I get the following error message:</p>

<blockquote>
  <p>Unable to find row in database table [requests] that
  matched attributes
  [{"first_name":"eyJpdiI6InFWbGJmSU9rR0NHMjFnMjR4QVVyalE9PSIsInZhbHVlIjoiaDBMcGNxYzdsRlhjNDd3M2E5OGxQbUVkaHhzdEpIOERDcytwQytzZUN4MD0iLCJtYWMiOiJlN2U2MzczYTlhMDgyYTMxOWJmMGQyZDU0MzFiMmZiZjhkMDM1ZjA2YWFhZGVkYTZhMGRkNGMzNDY0ZTAzMjZmIn0="}].</p>
</blockquote>

<p>I tried to manually check to see if the record existed after being created and it did not show up. I remember reading something about data not persisting when running tests, so that would make sense... But are you able to think of any reasons why it wouldn't be able to find that record during the test?</p>