[TYPO3-mvc] RFC: Using PHPUnit for testing controller - a tutorial

Michael Knoll mimi at kaktusteam.de
Tue Jan 12 11:25:29 CET 2010


Hi Masi,

I think that's one of the "important" questions. Perhaps I did not 
express myself in a good way. What the controller should be doing in the 
tested action is retrieving a result from a repository and put it into 
the view.

We do not want to test the repository (that must be another test) and we 
do not want to test the content of the repositories response. The only 
thing we want to make sure is that the controller puts the result into 
the view using the correct key. And that's what I'm doing here.

Please note that my English might be not very expressive - so all I am 
writing is a "RFC" expressing my thoughts which can be or should be 
discussed here.

If you think that this is not a good example of how to test a 
controller, please let me know, then we can perhaps try somethin else...

Most important for me is having a simple method to check whether all 
Business logic can be used in a correct way in the controllers after we 
change something - that should make refactoring a lot easier.

Greetings

Michael




Martin Kutschker schrieb:
> Michael Knoll schrieb:
>> Hi there,
>>
>> as I promised in one of my last posts, I wrote a small tutorial on how
>> to test ExtBase controllers using PHPUnit. Thanks to Jochen Rau, which
>> gave me some nice hints.
>>
>> You can find my Blog-Entry here:
>>
>> http://alturl.com/sgpf
>>
>> Please comment on this and let me know, what you think about it...
> 
> I didn't use PHPunit so far in real life so my question may be dumb. How is the action actually
> tested? I think I understand roughly the set up of the mock objects. What I don't understand is
> where is the state of the view tested once indexAction() is called. That would be b) quoting your
> blog entry:
> 
> "b) want to check to make sure, the view holds the data we want it to hold, after the action is
> performed"
> 
> I see no code that retrieves "galleries" and checks it's expected type (and value?).
> 
> Masi


More information about the TYPO3-project-typo3v4mvc mailing list