phpunit - Testing Static function -
phpunit - Testing Static function -
i newbie testing. using phpunit framework. read mocking , stubbing static functions concepts new me. want unit test next function
class company implements iform { public $id = null; public $externalid = null; public $name = null; public $created = null; public $modified = null; public $state = null; private $arrservice = array(); public function __construct($externalid, $name, $state) { $this->externalid = $externalid; $this->name = $name; $this->state = $state; } public static function factoryfromobject($obj) { $c = new company($obj->external_id, $obj->name, $obj->state); // tag $c->id = $obj->id; $c->created = $obj->created; $c->modified = $obj->modified; homecoming $c; } }
what have done far next
class companytest extends phpunit_framework_testcase { private $company; public function testfactoryfromobject() { $this->company = new company( 004 ,'companyname','state'); $returnobject = $this->company->factoryfromobject($this->company); $expectedid = $this->company->id; $expectedcreated = $this->company->created; $expectedmodified = $this->company->modified; $actualid = $this->returnobject->id; $actualcreated = $this->returnobject->created; $actualmodified = $this->returnobject->modified; assertequals($expectedid, $actualid); assertequals($expectedcreated, $actualcreated); assertequals($expectedmodified, $actualmodified); } }
i next error:
undefined property: company::$external_id
how can test function, help great, thanks.
testing phpunit
Comments
Post a Comment