title: PHPUnit and seams
body: <p>So I've decided to investigate using seams in PHPUnit, but I came across a problem</p>
  
  <p>I rearranged my class in a way that I broke the dependencies to database class</p>
  
  <pre><code>db_Class::getMyData($vars);
  </code></pre>
  
  <p>became</p>
  
  <pre><code>self::getMyData($vars);
  </code></pre>
  
  <p>and I added functions to my code</p>
  
  <pre><code>protected static function getMyData($vars) {
      return db_Class::getMyData($vars);
  }
  </code></pre>
  
  <p>This was done so I can make a class that inherits this class and overloads the getMyData function. To be able to alter it when I run my test cases.</p>
  
  <p>So for example in the seam class that extends the class above and overloads that function:</p>
  
  <pre><code>protected static function getMyData($vars) {
      return array('id'=&gt;1, 'name'=&gt;"My Name");
  }
  </code></pre>
  
  <p>This would be very useful, as I can alter the data as I like. However when using PHPUnit you have the possibility to run mocks using $this->getMock and similar. Would I ever be able to achieve this inside the seam class.</p>
  
  <p>I'm trying to look for a solution where I am not using a dependency injector, which would be my other alternative, not so bad at all, just want to evaluate both alternatives.</p>
  
  <p>Michael C. Feathers expressed a seam to be the following:</p>
  
  <pre><code>A seam is a place where you can alter behavior in your program without editing in that place.
  </code></pre>
  
  <p>So I might not get the full picture, and I've been trying to get it for a while now, and I just cant get my head around it. Please comment if you have any ideas or questions.</p>
  
  <p>What I ask for is a way to work with mocks easy in different scenarios. I dont always want to return the same value in the seam, sometimes I want to return null to get an error, and sometimes an array with correct data, and sometimes something else probably.</p>
  
  <p>Thanks</p>