It does not matter, no. All the assert methods are defined as static so using self:: is the "correct" way to call them but php allows you to call them as instance methods. Your editor (and/or static analysis) may complain about calling them this way.
It's really just personal preference. I think it's important to have consistency - choose one way or the other for your app.
3 Comments
Hi,
Just in case a stupid question
Does it has difference :
$this->assertEquals(1,1);
and
self::assertEquals(1,1);
Hey @Ruslan, great question!
It does not matter, no. All the assert methods are defined as static so using
self::is the "correct" way to call them but php allows you to call them as instance methods. Your editor (and/or static analysis) may complain about calling them this way.It's really just personal preference. I think it's important to have consistency - choose one way or the other for your app.
Hope that clears things up!
Thank you!
"Houston: no signs of life"
Start the conversation!