title: Laravel Unit Testing with MongoDB and Object arrays
body: <p>Hello I'm pretty new to PHPUnit and Laravel 4.
  I've created an REST API and I'm trying to add a new User using laravel (PHPUnit) unit tests, to my test DB. The problem is, that it completely disregards the Object array that I'm trying to add with the user doc creation.</p>
  
  <p>A typical User Doc would look as follows:</p>
  
  <pre><code>{
      _id": ObjectId("53021089b4d15220118b4568"),
     "oArr": {
       "something": {
            "somewhere": "5th Avenue",
            "ip": "192.168.0.20"
       },
       "something2": {
            "somewhere": "6th Avenue",
            "ip": "192.168.0.21"
       }
    }
     "email": "jessica@example.com",
     "name": "Jessica Alba",
     "password": "$2y$10$RAVzUGLAG.81IOOUum0k0u5vrcY98H.L42FeSJekEywUCV.ycttn6"
  }
  </code></pre>
  
  <p>Now Laravel has it's own Testing class <code>TestCase</code> which your Unit tests extend.
  Typical example would be the following:</p>
  
  <pre><code>class AddUserTest extends TestCase {
  
      /**
       * A basic functional test example.
       *
       * @return void
       */
  
  
      public function testCreateUsers()
      {
        $post_data = array(
            'email' =&gt; 'emma@example.com',
            'name' =&gt; 'Emma Watson',
            'password' =&gt; 'password',
            'oArr' =&gt; array(
                'something' =&gt; array(
                    'somewhere' =&gt; '7th Avenue',
                    'ip' : =&gt; '192.168.0.31'
                ),
            ),
        );
      }
  }
  </code></pre>
  
  <p>Once the user test has run (successfully), the new Emma Watson user (Mongo Doc) look as follows:</p>
  
  <pre><code>{
      _id": ObjectId("53021089b4d15220118b4568"),
     "email": "emma@example.com",
     "name": "Emma Watson",
     "password": "$2y$10$asdAzUGLAG.8asvWQOUum0k0u5vrcY98H.LEDeSJekEywUCV.ycttn6"
  }
  </code></pre>
  
  <p>I have no idea how, and couldn't find anyone else with the same problem.</p>
  
  <p><strong>My assumption:</strong> The ORM I'm using (<a href="https://github.com/jenssegers/Laravel-MongoDB" rel="nofollow">https://github.com/jenssegers/Laravel-MongoDB</a>), doesn't cater for Object arrays in Unit Tests.</p>
  
  <p>I have yet to look into how the ORM is handling unit tests, I'm just hoping someone else has had the same problem, and has a more basic solution.</p>