On Tue, Oct 5, 2010 at 10:58 PM, Bulat Shakirzyanov <[email protected]>wrote:

> Hi Lukas,
>
> I personally don't think its possible to refactor the mock setup and reduce
> duplication.
> It might seem annoying that you have to instantiate mocks all the time and
> pass 6-7 parameters, but the mocks are very domain specific, as they are to
> test how your application interacts with them.
>

I fully concur with this. What a framework can do at its best is to provide
quicker or test-friendly way to bootstrap (e.g.
Symfony\Bundle\FrameworkBundle\Tests\Kernel) as well as proper design to
avoid hidden state changes (e.g. this is when I avoid having logical stuff
in constructor).

What I see possible however is for Symfony2 to provide ApplicationTestCase,
> where you could get mocked instances of Templating engine, and other widely
> used services (don't use others that much), which you could then extend to
> not write the same functions twice.
>
> Thoughts?
>

+1 too. I usually write my own application/functional abstract test cases
that have done certain mocking setups (or abstract methods to simplify
mocking, e.g. protected function mockViewWhen())

Btw, what PHPUnit lacks of is providing a good mocking experience (see
Mockito - http://mockito.org/).



> Best,
> Bulat
>
> On Tue, Oct 5, 2010 at 8:17 AM, Lukas Kahwe Smith <[email protected]>wrote:
>
>> Hi,
>>
>> If you look at Bulat's recent controller testing example you can see that
>> he needs to mock the templating service:
>> http://avalanche123.com/post/1215273326/symfony2-controller-testing
>>
>> As you can see in the comments, its actually not that easy, since the
>> templating service needs to be told to either not call the constructor or it
>> needs yet another services mocked and injected.
>>
>> Now imho it would be nice if the DIC would provide some solution to
>> automate the creation of mock objects. Obviously one would still need access
>> to the mock objects (which might not be guaranteed in all cases) in order to
>> add expects() etc. But it could be a huge timesaver.
>>
>> regards,
>> Lukas Kahwe Smith
>> [email protected]
>>
>>
>>
>> --
>> If you want to report a vulnerability issue on symfony, please send it to
>> security at symfony-project.com
>>
>> You received this message because you are subscribed to the Google
>> Groups "symfony developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]<symfony-devs%[email protected]>
>> For more options, visit this group at
>> http://groups.google.com/group/symfony-devs?hl=en
>>
>
>  --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<symfony-devs%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/symfony-devs?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to