10/06 2013
EXT:builder - yes we can!

A new Fluid Powered TYPO3 family extension is coming - this time, it's a support utility to further increase your productivity and ensure code quality.

Dear developers

A new extension is coming - EXT:builder. When installed in a development TYPO3 site (which is the only place it should ever be installed), this extension currently provides:

 

  • A CLI command for syntax checking every PHP file in an extension - or a specific file. Useful for Phing / Travis / Jenkins scripts (internally uses PHP Lint checking so requires no additional code or modules in PHP; just the "php" CLI command).
  • A CLI command for syntax checking every Fluid template file (formats can be specified). Will detect things like unclosed ViewHelper tags, unknown arguments). Can also output verbose information about templates - which Layout they use, for example. Planned additions in this syntax checker is to check if the Layout is present, if all Partials and sections are present and so on - to make detection of problems a breeze.
  • A CLI command for generating ViewHelper unit test case classes for every class in an extension - or just a single class. The generated unit test cases cover about 50% of code that's present in standard ViewHelpers (injection, argument preparation, ViewHelperNode capability, etc). Planned additions include a generic way to test arguments - if arguments do not contain dynamic variables (and to the extent special classes can be supported) as well as a way to run PHPUnit immediately after creating a new test. With these coming improvements it is my hope that code coverage in auto-generated ViewHelper test cases can reach a fair 80% minimum and is able to provide instant feedback - thus finishing 80% of this particular task with a single command. Toggles for file overwriting behavior and dry run are provided. Generated classes are marked and can be automatically overwritten as the ViewHelper class they test are elaborated.

Each of these CLI commands use a parameter which can react to a single class or filename, making them ideal for use as triggered commands when saving files (or in file access monitors, scheduler tasks etc) to keep your back clear while you develop your extensions. They are also ideal for use in for example Travis build scripts, by fully automating tests of Github pull requests to validate PHP syntax, Fluid template consistency - or even on-the-fly generation of unit tests which cover newly submitted ViewHelper classes even before any actual unit tests get written.

The above is what the extension is currently capable of doing, but true to my nature I won't stop there. I also have loose plans to include:

 

  • Annotation validation: defined Validator exists, used annotations (fx @var, @throws, @return) use proper and existing classes, etc.
  • Unit test generation for Controller classes, including validation of annotations for validation, request has verification and so forth. Since Extbase Controller classes are very regular in nature, it's possible to use the Reflection framework to analyse methods and determine how a test should be constructed. While this is still just an idea, I have an expectation of being able to cover around 50%-70% of the code in Controller classes with automatically generated unit tests.
  • Unit test generation for Utilities/Services/DomainObjects/Repositories which use simple argument values and expect simple return values. I expect to be able to reach a modest 80%-100% code coverage in these class types. Yes, it's true that much of this generation can happen in EXT:extension_builder, but there are some of us who prefer the manual way - or simply want to generate new unit test classes after initially constructing the extension in EXT:extension_builder.
  • Kickstarting of "Fluid Powered TYPO3" extensions, page- and content templates - initially in the form of a CLI command but in time, perhaps also a BE module and perhaps even a graphical utility to go along with it, รก la TemplaVoila.

The extension has not yet been published to TER and is still somewhere around beta stability, slightly lower. It still needs a bit of polishing before actual release but the features can be used safely on extensions that don't yet contain any ViewHelper unit tests (and of course the syntax checking commands don't modify files and can be always be used safely).

Clone the Github repository at <link https: github.com fluidtypo3 builder>github.com/FluidTYPO3/builder to your typo3conf/ext folder and install the extension. Clear all caches and execute in CLI:

localhost:mywebroot claus$ ./typo3/cli_dispatch.phpsh extbase help

...to see the list of commands. Then:

localhost:mywebroot claus$ ./typo3/cli_dispatch.phpsh extbase help <command>

...to see a list of supported arguments for each command. Try each one out, fix any warnings it gives about your code, generate a full collection of ViewHelper unit tests (currently covering ~50% of all ViewHelper code) - and enjoy the increased quality of your extension :)

Cheers,
Claus

PS: In a short time I'll be writing a blog article about using Travis Continuous Integration with Extbase/Fluid extensions - and supplementing the build script with the syntax checks provided by EXT:builder.

 

Archive

09/01 2017
09/11 2016
09/06 2016
21/12 2015
07/12 2015
25/11 2015
25/09 2015
22/09 2015
01/08 2015
10/03 2015
03/03 2015
12/02 2015
25/11 2014
01/11 2014
16/10 2014
02/10 2014
02/10 2014
19/09 2014
18/09 2014
05/09 2014
22/08 2014
02/08 2014
27/06 2014
06/06 2014
13/04 2014
27/03 2014
12/03 2014
11/03 2014
05/02 2014
25/01 2014
17/12 2013
08/12 2013
03/12 2013
04/11 2013
Flux 7.0 Teaser
06/08 2013
21/07 2013
10/06 2013
04/06 2013
01/06 2013
27/05 2013
19/05 2013
19/05 2013
11/05 2013
26/04 2013
30/03 2013
19/03 2013
17/03 2013
13/03 2013
10/03 2013
10/03 2013
05/03 2013
04/03 2013
03/03 2013
02/03 2013
01/03 2013
28/02 2013
27/02 2013
25/02 2013
24/02 2013
24/02 2013
23/02 2013
10/02 2013
03/02 2013
03/02 2013
27/01 2013
Asset management in Fluid
20/01 2013
16/01 2013
13/01 2013
08/01 2013
16/12 2012
25/11 2012
18/11 2012
08/11 2012
07/11 2012
05/11 2012
04/11 2012
28/10 2012
22/10 2012
14/10 2012
13/08 2012
08/08 2012
31/07 2012
30/07 2012
25/07 2012
29/04 2012
29/04 2012
22/04 2012
16/04 2012
21/03 2012
Flux 1.4.0 released
08/03 2012
Flux 1.3.0 released
04/03 2012
03/03 2012
28/02 2012
19/02 2012
A Sneaky Sneak Preview of the next version of Flux
13/02 2012
12/02 2012
06/02 2012
30/01 2012
27/01 2012
15/01 2012
26/12 2011
24/12 2011
11/12 2011
11/12 2011
10/12 2011
04/12 2011
04/12 2011
30/11 2011
26/11 2011
25/11 2011