lundi 24 août 2015

PHP Unit: Create common object to work with

I'm writing PHP Unit tests for a class, which make some curl requests. At the moment every test starts with my class instance initiation and login directive and ends with logout directive, e.g.

public function testSomeMethod(){
        $a = new myClass();
        $a->login();
        ....
        $a->logout();
        $this->assertTrue($smth);

I want to create one common object $a = new myClass(), call login method before all test and logout method after all tests. How can I do that?

Aucun commentaire:

Enregistrer un commentaire