Tag: unit testing
-
Symfony 2: Why You Should Move Your Logic into a Service
In typical MVC applications, people end up storing business logic into either the controller or the model layer. The problem in this approach is that in either case, you introduce code bloat and dependencies that should not really exist. Controllers, which are essentially the observer pattern, act as a traffic light, taking requests and directing…
-
Symfony 2: Form Data Submit and Models with Validation Unit Testing Issue
While creating a phpunit test against a form for Symfony 2, I encountered an interesting problem that made little sense to me at first (for reference, I was following an example for unit testing form types from the Symfony 2 website). The problem was that the data being submitted appeared to not be mapped correctly,…
-
Symfony 2: Unit Testing Many-to-One Validations on Entities
From what I can tell, the Symfony 2 cookbook does not have a decent example for handling entity validations and unit testing. I looked around a bit for a good sample and found a decent answer over on Stackoverflow. But outside of setting up a base class for handling future validation test classes, the sample…
-
Unit Testing: Why Testing for Failures First is Good
As an experienced software developer, I consider myself extremely paranoid and cynical. Well, there’s the world-at-large aspect (which might be a bane to my existence) but there’s the software aspect, where lacking trust of what you develop is a GREAT thing. No matter how complex nor simple of an application or function you can write,…