php - How to share fixtures between tests in PHPUnit -


i'm doing wordpress functional testing read html , use mastermind/html5 transform test. however, tests getting slow because loading html document takes around 1s per test. i'd share fixture between tests don't have parse each test. have 1 constraint, method gets html in parent class non-static method

https://core.trac.wordpress.org/browser/trunk/tests/phpunit/includes/testcase.php?rev=32953#l328

what choice have share fixture between tests.

here's example code

class testcase extends wp_unittestcase {      public function setup() {         parent::setup();     }      public function get_dom( $path ) {         $html = $this->go_to( $path ); // cannot change method         // html parsing , return dom     }  } 

here's sample test

class testcase1 extends testcase {      public setup(){           $this->dom = $this->get_dom('/')      }      public test_1() {      }       public test_2() {      } } 

i thinking of making method get_dom static called once far know static method cannot call non-static method. correct? , if yes there anyway share fixture between tests?

do mean cache data "dom"? try this:

public function setup() {      static $dom;      if (!isset($dom)) {          $dom = $this->get_dom('/');      }       $this->dom = $dom; } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -