twig - failure with find() function using PHP with Silex -


here failure message in terminal running 'phpunit tests':

1) stylisttest::test_find null not match expected type "object".

/users/evanbutler/desktop/hairsalonapp/tests/stylisttest.php:163

here's test method:

function test_find()   {     //arrange     $name = "stylist jane";     $id = 1;     $name2 = "stylist bob";     $id2 = 2;     $test_stylist = new stylist($name, $id);     $test_stylist->save();     $test_stylist2 = new stylist($name2, $id2);     $test_stylist2->save();      //act     $result = stylist::find($test_stylist->getid());      //assert     $this->assertequals($test_stylist, $result);   } 

and here's method:

static function find($search_id)   {     $found_stylist = null;     $stylists = stylist::getall();     foreach($stylists $stylist) {       $stylist_id = $stylist->getid();       if ($stylist_id == $search_id) {         $found_styist = $stylist;       }     }     return $found_stylist;   } 

here's getall method:

static function getall()   {     $returned_stylists = $globals['db']->query("select * stylists;");     $stylists = array();     foreach($returned_stylists $stylist) {       $name = $stylist['name'];       $id = $stylist['id'];       $new_stylist = new stylist($name, $id);       array_push($stylists, $new_stylist);     }     return $stylists;   } 

if you'd see files here's link git repository: https://github.com/evanb2/hairsalonapp.git

i've been staring @ way long , i'm totally stumped.

change

$found_styist = $stylist; 

to

$found_stylist = $stylist; 

you need better ide man. simple static analysis tell unused variable.


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

java - Could not locate OpenAL library -

Non Unique Username with ASP.Net Identity 2.0 -