[TYPO3-mvc] UnitTests for Controller
dennis ahrens
dennis.ahrens at googlemail.com
Thu Nov 26 11:21:11 CET 2009
Hi Sebastian,
in my case the controller is just calling some methods on a parser
which build up a object and adds it to the repository.
Looks like this:
public function importAction($xmlFile) {
$this->parser->loadXMLFile($xmlFile,'documenttemplate.xsd');
if($this->parser->validate()) {
$documentTemplate = $this->parser->convertIntoObject();
$this->documentTemplateRepository->add($documentTemplate);
}
}
do you think it's best practice to write tests for all service methods
and don't write tests for the controller at all?
regards
Dennis
Am 26. November 2009 07:52 schrieb Sebastian Kurfürst <sebastian at typo3.org>:
> Hey Dennis,
>
> Controllers are really hard to test because they have so many
> dependencies... What is your controller doing?
>
> In most cases, I'd rather suggest to put the difficult functionality to
> a Service, and keep the controller slim and lean.
>
> Greets,
> Sebastian
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
More information about the TYPO3-project-typo3v4mvc
mailing list