/**
  * Comparaison function for members
  * Ascending order for name and then firstName
  * 
  * @param \AppBundle\Entity\Member $m1
  * @param \AppBundle\Entity\Member $m2
  * @return number (-1, 0 or 1 if $m1 is inferior, equals or superior to $m2)
  */
 private function compareMembers(Member $m1, Member $m2)
 {
     $result = strcmp($m1->getName(), $m2->getName());
     if ($result == 0) {
         $result = strcmp($m1->getFirstName(), $m2->getFirstName());
     }
     return $result;
 }
 private function checkMember(Member $member, array $formattedArray)
 {
     $this->assertArrayHasKey('id', $formattedArray, 'Check "id" key');
     $this->assertArrayHasKey('name', $formattedArray, 'Check "name" key');
     $this->assertArrayHasKey('firstName', $formattedArray, 'Check "firstName" key');
     $this->assertArrayHasKey('phone', $formattedArray, 'Check "phone" key');
     $this->assertEquals($formattedArray['id'], $member->getId(), 'Check "id" value');
     $this->assertEquals($formattedArray['name'], $member->getName(), 'Check "name" value');
     $this->assertEquals($formattedArray['firstName'], $member->getFirstName(), 'Check "firstName" value');
     $this->assertEquals($formattedArray['phone'], $member->getPhone(), 'Check "phone" value');
 }
Esempio n. 3
0
 /**
  * Format a Member to build a JSON-compatible array
  * 
  * @param \AppBundle\Entity\Member $member
  * @return array
  */
 private function formatMember(Member $member)
 {
     return array('id' => $member->getId(), 'name' => $member->getName(), 'firstName' => $member->getFirstName(), 'phone' => $member->getPhone());
 }