Yii2 testing environment guidelines for extension development

[size="2"] Hi Folks!

I am developing an Yii 2 public (MIT) extension to change some of the yii\web\View behaviours (minify, combine and many other optimizations). I can do it easily. But I really want to write as many tests (codeception) as possible for it. This is where I am very confused.

I already have some unit tests (for example: testing a specific minifing, or returning combined minified result). But I would like to test the entire result and the final integration between my extension and the Yii2 web application using it.

I just would like some guidelines for this process:[/size]

  • [size=“2”]1) Would you use functional testing ? (I think so because the View will find files in AssetBundles, combine and minify them, publish the result as a single file and replace the assets’ urls by new url (i.e., the optimized asset url) inside the view;[/size]

  • [size=“2”]2) Should I have a real (complete) app inside my extension for testing purposes? If so, should it be ‘installed’ inside tests dir?[/size]

  • [size="2"]3) Could you provide some very basic examples, start points, guidelines or any help thing else?


[size="2"]I just would like to highlight that I dont intend you do the things, I really want to learn how to do them. This is why I really would be very grateful for any tips.

[/size][size="2"]Thank you so much.


Ok, I had already seen some core yii2 extensions to find some guidelines, but now, paying attention, I found one using mocked view (smarty). It seems it will be enough to understand the guidelines (I hope).



I have finished the extension (initially, for particular use) and now I am making it available publicly. Hope it can be useful for anyone more.

More information here: https://github.com/slinstj/yii2-assets-optimizer