title: PHPUnit::How can be __construct with protected variables tested?
body: <p>PhpUnit::How can be __construct with protected variables tested?</p>
  
  <p>(not always we should add public method getVal()- soo without add method that return protected variable value)</p>
  
  <p><strong>Example:</strong></p>
  
  <pre><code>  class Example{
      protected $_val=null;
      function __construct($val){
        $this-&gt;_val=md5 ($val);
      }
     }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>also exist  problem to test in function that return void</p>
  
  <hr>
  
  <p><strong>Edit2:</strong></p>
  
  <p>Example why we need test __construct:</p>
  
  <pre><code>class Example{
          protected $_val=null;
         //user write _constract instead __construct
          function _constract($val){
            $this-&gt;_val=md5 ($val);
          }
  
         function getLen($value){
           return strlen($value);
         }
   }
  
   class ExampleTest extends PHPUnit_Framework_TestCase{
       test_getLen(){
         $ob=new Example();//call to __construct and not to _constract
          $this-&gt;assertEquals( $ob-&gt;getLen('1234'), 4);
       }
   }
  </code></pre>
  
  <p>test run ok, but Example class "constructor" wasn't created!</p>
  
  <p>Thanks</p>