Given the following methods:

public function setFoo($foo) {
    $this->_foo = $foo;
    return $this;
}

public function getFoo() {
    return $this->_foo;
}

Assuming, they may be changed to be more complex in the future:

  • How would you write unit tests for those methods?
  • Just one test method?
  • Should I skip those tests?
  • What about code coverage?
  • How about @covers annotation?
  • Maybe some universal test method to implement in the abstract test case?

(I use Netbeans 7)

This seems like a waste of time, but I wouldn't mind if IDE would generate those test methods automatically.

To qoute from the comment of Sebastian Bergman's blog:

(it's like testing getters and setters -- fail!). In any case, if they were to fail; wouldn't the methods that depend on on them fail?

So, what about the code coverage?

Edit
Report