title: PHPUnit: Test array of objects
body: <p>Just jumped into PHPUnit recently, have been reading stuff about it, trying out some examples, in order to get comfortable in writing the tests for my future projects. </p>
  
  <p>I need to test this scenario, I have Students Class which is like this: </p>
  
  <pre><code>class Students
  {
      public function getStudents($studentName, $studentId)
      {       
          $students= array();
  
          //Instantiating OldStudent Class from Old Project
          $oldStudents = \OldStudents::getStudentByName($studentName, $studentId);
  
          //Create a Student Object for every OldStudent found on Old Project and set
          //values
          foreach ($oldStudents as $oldStudent)
          {            
              $student = new \Entity\Student();
  
              //Set Student ID
              $student-&gt;setStudentId($oldStudent-&gt;getStudentID());
  
              //Set Student Name
              $student-&gt;setStudentName($oldStudent-&gt;getStudentName());    
             //.....other setters for student data, irrelevant for this example 
  
              $students[] = $student;            
          }
  
          return $students;
      }
  }
  </code></pre>
  
  <p>And the Student Class</p>
  
  <pre><code>Class Student
  {
      protected $studentId;
      protected $studentName;
  
      public function getStudentId()
      {
          return $this-&gt;studentId;
      }
      public function setStudentId($studentId)
      {
          $this-&gt;studentId = $studentId;
          return $this;
      }
      public function getStudentName()
      {
          return $this-&gt;studentName;
      }
      public function setStudentName($studentName)
      {
          $this-&gt;studentName = $studentName;
          return $this;
      }   
  }
  </code></pre>
  
  <p>Now how can I test whether the <strong>Students</strong> Class returns an array of objects with the values set and check the values be using the getters from <strong>Student</strong> Class</p>
  
  <p>Please do throw some light/information/links whichever directs me in the correct path.</p>
  
  <p>Thanks</p>