title: How to test an array object in phpunit?
body: <p>I have a static function is given below: want to test this function using PHPUnit</p>
  
  <p><strong>One.php:</strong></p>
  
  <pre><code>static function myArray(myArrays $one) {
      $data = [
          "Name" =&gt; "name",
          "id" =&gt; "_id",
          "addressLine1" =&gt; "address1",
          "town" =&gt; "town",
          "district" =&gt; "district",
          "country" =&gt; "country",
          "mobile" =&gt; "mobile_number",
          "email" =&gt; "email",
          "url" =&gt; "_url"
      ];
      $output = [];
  
      foreach ($data as $myDatas =&gt; $value) {
          if ($one-&gt;truthy($myDatas)) {
              $field = $one-&gt;getField($myDatas);
              $output[$value] = $field; 
          }
      }
      $output['country'] = strtolower($oneninetwo-&gt;getField("countryCode", ""));
  
  
      return $output;
  }
  </code></pre>
  
  <p>I have created a JSON file for this tests:</p>
  
  <pre><code>{ 
      "success":true,
      "data":{ 
         "id":"0001",
         "name":"Pizza",
         "addressLine1":"001 Down Town",
         "addressLine2":null,
         "addressLine3":null,
         "country":"AU",
         "countryCode":"au";
         "mobile":0123456789,
         "email":"test@test.com"
      }
   }
  </code></pre>
  
  <p>My tests:</p>
  
  <pre><code>public function testmyArray() {
      $mockreg = $this-&gt;getMockRegistry();
  
      $json = file_get_contents(__DIR__."/src/myjson.json");
  
      $data = json_decode($json, true);  
  
      $name = $data['data']['name'];
      $addressLine1 = $data['data']['addressLine1'];
      $addressLine2 = $data['data']['addressLine2'];
      $addressLine3 = $data['data']['addressLine3'];
      $mobile = $data['data']['mobile'];
  
      self::assertEquals($name, "Pizza");
      self::assertEquals($addressLine1, "001 Down Town");
      self::assertNull($addressLine2);
      self::assertTrue(is_numeric($mobile));
  
  
      $test = new class() extends One{ 
          function __construct() {
             $this-&gt;myArray();
  
             ----
          }
      };
  
  }
  </code></pre>
  
  <p>Now want to tests the <code>One</code> class returns an array of objects with a value set and check the values?</p>
  
  <p>Is this a good way to test or another way to test the array objects?</p>
  
  <p>Any help?</p>