title: phpunit: How do I pass values between tests?
body: <p>I'm really running into a brick wall with this. How do you pass class values between tests in phpunit?</p>
  
  <p>Test 1 -> sets value,</p>
  
  <p>Test 2 -> reads value</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class JsonRpcBitcoinTest extends PHPUnit_Framework_TestCase
  {
      public function setUp(){
          global $configRpcUser, $configRpcPass, $configRpcHost, $configRpcPort;
  
          $this-&gt;bitcoindConn = new JsonRpcBitcoin($configRpcUser, $configRpcPass, $configRpcHost, $configRpcPort);
          $this-&gt;blockHash = '';
      }
  
      /**
      * @depends testCanAuthenticateToBitcoindWithGoodCred
      */
      public function testCmdGetBlockHash()
      {   
          $result = (array)json_decode($this-&gt;bitcoindConn-&gt;getblockhash(20));
          $this-&gt;blockHash = $result['result'];
          $this-&gt;assertNotNull($result['result']);
      }
  
      /**
      * @depends testCmdGetBlockHash
      */
      public function testCmdGetBlock()
      {   
          $result = (array)json_decode($this-&gt;bitcoindConn-&gt;getblock($this-&gt;blockHash));
          $this-&gt;assertEquals($result['error'], $this-&gt;blockHash);
      }
  }
  </code></pre>
  
  <p><code>testCmdGetBlock()</code> is not getting the value of <code>$this-&gt;blockHash</code> that should be set in <code>testCmdGetBlockHash()</code>.</p>
  
  <p>Help in understanding what is wrong would be greatly appreciated.</p>