/** * @expectedException InvalidArgumentException */ function testGetObjectByPropertyButNo() { $obj1 = new stdClass(); $obj1->name = 'mark'; $obj1->skill = 'acro yoga'; $obj = TimberHelper::get_object_by_property($obj1, 'skill', 'cooking'); }
function testGetObjectIndexByProperty() { $obj1 = new stdClass(); $obj1->name = 'mark'; $obj1->skill = 'acro yoga'; $obj2 = new stdClass(); $obj2->name = 'austin'; $obj2->skill = 'cooking'; $arr = array($obj1, $obj2); $index = TimberHelper::get_object_index_by_property($arr, 'skill', 'cooking'); $this->assertEquals(1, $index); $obj = TimberHelper::get_object_by_property($arr, 'skill', 'cooking'); $this->assertEquals('austin', $obj->name); }