On how to test if the setting worked see @Gordons answer.
I'd like to argue that you don't need to test that though.
Your unit tests should make sure the public API of your class works as expected. You don't care (for the sake of testing) how your values are stored internally so you don't need to make assertions on it. Doing it that way also makes your tests only test what your class does and not how the class does it
The point is that you shouldn't have to change your tests when you change your class without affecting what it does
For the sake of the argument let's say SomeClass is something that in the end spits out HTML.
class SomeClass {
public function setValue($name, $value)
{
// do some stuff
}
public function doSomething(array $values)
{
foreach ($values as $name=>$value) {
$this->setValue($name, trim($value));
}
}
public function createHTML()
{
$return = "";
foreach($this->values as $key => $value) {
$return .= "<div is='$key'>$value</div>";
}
return $return;
}
}
If that is everything your class does an absolutely sufficient test for that class could look like this:
class SomeClassTest extends PHPUnit_Framework_TestCase {
public function testHtmlGenerationWithTwoValuesSet() {
$o = new SomeClass();
$o->setValue("foo", "bar");
$o->setValue("x", "y");
$result = $o->createHTML();
$this->assertSame(
2,
substr_count("<div>", $result),
"There should be as many divs as there are values set"
);
$this->assertTrue(
strpos("<div>bar</div>") !== false
"String should contain a set value enclosed in divs"
);
}
}
Again: It is about testing behavior of your class, not testing every method on its own. Your test suite will be much more valuable if you got about it this way
While the example with html might not be the right one it shows how to test behavior pretty nicely (i hope)