Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Well, if it had magic getters and setters.. :)
wick3dpoison4043dYet the following unit test fails:
$testCase->foo = "bar";
@rooter I almost wish. The "logic" is rather dumb. The only thing that happens under the hood is that objects (and array of objects) are converted to an array via reflection and the only "transformation" worthy of note is that numeric values are always casted to floats. The rest is stored as is. Nothing special going on. The test case makes it seem like something super important is going on, when in fact, the results only change because the mock was changed.
It's code for the sake of writing code.
One unit test with dummy data would have sufficed. (And that one already exists.)
For web applications nothing tests like Cyprus / Selenium.
I worked at a company with literally everything tested one level deep per function using mocks. In theory it should be OK. But in reality the few cypress tests tested ten times better.
Mocks are just simple and easy to write. Doesn't take much time but indeed, what do they test often?
Stay away from __get / __set .
You will fuck up sooner than later.
I think (hope?) the message parameter was left out to shorten the rant.
Nothing is more pervert than writing in an test failure message the expected value.
The message is there to describe the behaviour (!) you test, so you know what should have happened.
Testing values makes no sense at all, author is right.
If you want to test automatic behaviour, it should be by invoking the method explicitly.
__get takes a String with the name of the attribute to test.
$testValue = 'bar';
$testClass = new testClass();
$testClass->Foo = $testValue;
"__get behaviour, expected value not returned."
That test case will fail compilation, too - if __get isn't implemented.
Which makes it obvious.