I had little dispute with my coworkers about unit testing simple class. I have to test simple class like that.
class Person
{
/** @var string */
protected $name
public function __construct(string $name)
{
$this->name = $name;
}
public function __toString(): string
{
return (string) $this->name;
}
}
We both agree on testing toString method. But in my opinion, first we have to test creating this object as such:
public function testObjectCreation()
{
$testSubject = new Person('name');
$this->assertInstanceOf(Person::class, $testSubject);
}
My question is: Is there any sense in testing this case?