cancel
Showing results for 
Search instead for 
Did you mean: 

PHP Static tests for front-end devs

PHP Static tests for front-end devs

I'm trying to add PHP Static test at Frontools to simplify and improve testing process and if it's possible increase performance, b/c it takes so long to get any results.

 

I'm not familiar with PHP testing libs / tools, so have few questions for you:

1. Is there any reason why M2 use testing libs (PHPUnit and PHP_CS) from 2014 instead of fresh one?

2. Is normal that output of this test looks like a mess and it's hard to understand what and where something wrong happens? I compare it with output of code quality tests for CSS/JS and it's nightmare. Is there any better reporter available or other way to get meaningful report, instead of something looking like a PHP backtrace?

3. Is there any reason why it's so slow? It take ~7-8 minutes to analyse template files. Most of front-end tests in worst case take a few seconds, so there is no way to get live feedback about issues.

4. How to run this type of tests when we have single module (i,.e. theme), not whole Magento 2?

5. It looks like PHP_CS has already a simple wrapper for Gulp, but I'm not sure where configuration is stored  In /.php_cs file?

1 REPLY

Re: PHP Static tests for front-end devs

Hi Bartek,

 

1. There is no reason. Magento updates libraries from time to time. Just that updating a library (e.g., phpunit) usually requires some updates in the tests. There is such item on the Magento backlog to update libraries.

2. Could you, please, provide examples? Here is an example of output from static tests - https://travis-ci.org/magento/magento2/jobs/155128815 

--------------------------------------------------------------------------------

FOUND 1 ERROR(S) AFFECTING 1 LINE(S)

--------------------------------------------------------------------------------

18 | ERROR | Use ::class notation instead.

--------------------------------------------------------------------------------

It looks pretty clear, I think: 18 - line number, ERROR - level of the issue, 'Use ::class notation instead.' - description.

3. Depends on your implementation. Do you analyze all template files? It would make sense to analyze only modified ones. If you're using phpcs, I think, this is a question to phpcs's performance. But I didn't notice performance issues with it, so can't suggest here.

4. W/o knowing how you implemented it, it's hard to tell. In general, specify only module's folder for the tests. I would not suggest reusing existing tests as is because they are intended for PHP classes more than templates and so, have rules that don't make sense for templates. It would be better to implement a separate test intended for your needs.

5. /.php_cs is for Git commits, I'm not sure if it may be somehow used with Gulp