Page 2 of 2

Re: The current mock object landscape.... bleak?

Posted: Sat Apr 12, 2008 7:36 pm
by Chris Corbyn
lastcraft wrote:The timescale is probably some 4-6 months away. Enough time for you to finish your more functionally complete Mockery version. After that, would you like to collaborate? In particular, would you consider joining the SimpleTest development team?

yours, Marcus
Sorry Marcus, I completely missed your last post somehow and only spotted a reply was made to this thread when you replied last night (Aussie hours!).

I'd be happy to collaborate yes, and joining the dev team would be an honour :)

Re: The current mock object landscape.... bleak?

Posted: Sun Apr 13, 2008 1:30 pm
by lastcraft
Hi...
Chris Corbyn wrote: Gotcha, but I still maintain that it a cause of a fragile test ;)
It is, but not for my much smaller tests :).
Chris Corbyn wrote: Have you looked at PHPMock?
Not yet. I have to get the test case mechanics sorted first, after we've done the 1.1 migration release.
Chris Corbyn wrote: Are we seeing a revolution?
I gave this talk at PHP|Tek a couple of years ago about how teaching OO to PHP'ers was going to have a broader "revolution" than in Java or Ruby. Something like writing moving from monastries to the printing press.

Right now the PHP community is still learning how to program. Fluent interfaces, DI, etc, are five years old, but are only now entering the more cutting edge PHP apps. Yet they come from the Java world. PHP's slant is CMS', blogs, RSS and the like. I think the real revolution will happen when these new skills and priorities (readable interfaces) reach the world of apps. Then they reach the world.
Chris Corbyn wrote: I assume your "or" on your code allows either one or the other but not both invocations?
Yes.
Chris Corbyn wrote: And if you used "and" would they have to come in that order?
No. That's what before and immediatelyBefore are for.
Chris Corbyn wrote: This was 90% of my reasoning for starting my own project and having that timing constraint slackened would possibly encourage me back again (Especially if Yay! doesn't pick up on interest... nobody wants to be using a testing tool others don't know how to use ).
Which is why I think joining SimpleTest (as well as YayMock) would give you a double bite of the cherry. I am going to keep my syntax though. I'ts been two years in the writing :).
Chris Corbyn wrote: Yay!'s list more or less come from jMock.
I wouldn't criticise JMock too heavily (especially as I know the authors personally), but it's Java centric, and without the IDE prompt you have a lot to remember. I reckon I can make the definitions about 25% smaller. Where I can't, I'll just copy JMock for compatibility.
Chris Corbyn wrote: I'm curious how well your new stuff will stand outside of SimpleTest? Is $this->MockResponse created in setUp() or is something going to be built into one of the base classes which handles this via __set() or such like?
It won't stand alone as it will be based on the upcoming plug-in fixture system. Here are the steps...

1) $this->MockResponse won't exist in the test case, so it drops through to __get().
2) The test case starts asking it's fixtures if they have that variable.
3) The MockObjects fixture will respond yes to anything starting "Mock".
4) Now we are in fixture land. It code generates the class on the fly.
5) The fluent stuff goes into a MockLogic prototype for that class.
6) Instantiating the mock causes it to get a clone of MockLogic (plus instance specific mods) for servicing it's calls.

SimpleTest however will have no dependency on the MockObjects fixture. The current mocks will become the LegacyMockObjects fixture for backward compatibility, but there would be nothing to stop YayMock or JMock providing an adapter and being used instead.
Chris Corbyn wrote: or you can use separate calls if needed:
Multiple calls set the default behaviour for every mock instance. If you want different behaviour per instance...

Code: Select all

 
$this->MockResponse[1]->setHeader('Location', 'http://google.com');
$this->MockResponse[2]->setHeader('Location', 'http://yahoo.com');
$reponse1 = new MockResponse();    // The Google one
$reponse2 = new MockResponse();    // The Yahoo one
 
Chris Corbyn wrote: You almost exactly described what's already available
Cool.

yours, Marcus