Better Formatter tests #120

merged 18 commits into from Feb 6, 2017


None yet

3 participants

bigfoot90 commented Jan 6, 2017 edited

Writing tests this way can be harden, but you can be sure that your feature/fix for an formatter type will not impact on any other formatter type.

If you think that can be useful I'll continue to write tests for the remaining tests cases.

codecov-io commented Jan 6, 2017 edited

Codecov Report

Merging #120 into master will increase coverage by -0.14%.

@@             Coverage Diff              @@
##             master     #120      +/-   ##
- Coverage     99.86%   99.73%   -0.14%     
- Complexity        0     1607    +1607     
  Files            54       54              
  Lines          3785     3787       +2     
- Hits           3780     3777       -3     
- Misses            5       10       +5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59f39f9...96a904a. Read the comment docs.

nijel commented Jan 7, 2017

I think this is good idea, just make sure that all things currently covered will stay covered.

+ " 1 # Comment" . "\n",
+ 'cli' =>
+ "\x1b[35mSELECT" . "\n" .
+ " \x1b[92m1 \x1b[37m# Comment\\x0A" . "\x1b[0m",
bigfoot90 Jan 8, 2017 Contributor

Found first issue writing tests.
Why there is a \x0A in the comment?

bigfoot90 Jan 8, 2017 Contributor

Fixing PR #123

@bigfoot90 bigfoot90 referenced this pull request Jan 8, 2017

Fix comment parsing #123

@nijel nijel self-assigned this Jan 17, 2017
nijel commented Jan 20, 2017

Any progress on this?


Yes, I was waiting for #123 to rebase onto.


I'm ready for the review, yo can see that every test case in testFormat is covered by the new tests in testFormat_new.
Any comments or suggestions?

Actually only the codacy/pr tests are failing, this will be resolved when I remove the old tests in testFormat and replace testFormat_new with testFormat.


I think it's pretty much ready to be merged, just rename the method and remove the old tests.

* Previous Token.
+ *
+ * @var Token $prev
nijel Jan 30, 2017 Member

This is really not variable declaration, so the comment does not make much sense here...

if ($prev !== null) {
+ /** @var Token $prev */
bigfoot90 Jan 30, 2017 edited Contributor

@nijel WDYT about this way?
I known that there is not a variable declaration, this way I say a bit different thig.
Here the annotation just says that there is a variable $prev of type Token.

This annotation is demanded by IDE, else it says that there is not any property value on null.

If it is not ok I can revert this one, no problem.

nijel Feb 2, 2017 Member

But $prev is declared before, I see no reason to have it annotated here...

bigfoot90 Feb 2, 2017 Contributor

There is already a annotation on the declaration (on line 325), but PhpStorm is simply ignoring it.

bigfoot90 added some commits Jan 6, 2017
@bigfoot90 bigfoot90 Begin writing new format queries tests 7f61c4b
@bigfoot90 bigfoot90 select with comment e4f6827
@bigfoot90 bigfoot90 Testing comments fd87828
@bigfoot90 bigfoot90 Rebased on top of master 73348fc
@bigfoot90 bigfoot90 Testing strip comments a067ee1
@bigfoot90 bigfoot90 Testing keywords 7368fdd
@bigfoot90 bigfoot90 Testing create procedure 8f857c0
@bigfoot90 bigfoot90 Testing Insert f810a7b
@bigfoot90 bigfoot90 Testing distinct count d92d5f9
@bigfoot90 bigfoot90 Testing string as alias ac5d4b1
@bigfoot90 bigfoot90 Testing escaping cli and escaping html 9dde9b8
@bigfoot90 bigfoot90 Testing create table 6242ca9
@bigfoot90 bigfoot90 Testing minimal and simply efdf6f3
@bigfoot90 bigfoot90 Fix test create table ce5781c
@bigfoot90 bigfoot90 Testing typical 74d4450
@bigfoot90 bigfoot90 And now?
@bigfoot90 bigfoot90 Remove @var

@nijel Removed @var anotation.
Are there other issues with this PR?
I can proceed to fix the method name testFormat_new and remove the old deprecated tests?

nijel commented Feb 4, 2017

I think it's in good shape, please go ahead.

@bigfoot90 bigfoot90 Remove old tests and fix method names 'formatQueries' and 'testFormat'
@nijel nijel merged commit 96a904a into phpmyadmin:master Feb 6, 2017

3 of 4 checks passed

codecov/project 99.73% (-0.14%) compared to 59f39f9
codacy/pr Good work! A positive pull request.
codecov/patch Coverage not affected when comparing 59f39f9...96a904a
continuous-integration/travis-ci/pr The Travis CI build passed
@nijel nijel added a commit that referenced this pull request Feb 6, 2017
@nijel nijel Fix expected format for BEGIN/END
Issue #120

Signed-off-by: Michal Čihař <>
nijel commented Feb 6, 2017

Thanks, I've merged it.

The coverage failure was caused by formatter handling differently BEGIN and begin as you've changed this. I've fixed this in 5fdfa5b and 1a11681 and adjusted tests accordingly in 65fb611.

bigfoot90 commented Feb 6, 2017 edited

Just to be clear. This way I'm testing that keywords are recognized and uppercased correctly.

nijel commented Feb 7, 2017

They were uppercased properly, but the formatting didn't recognize because of being lowercase...

@bigfoot90 bigfoot90 deleted the bigfoot90:better-formatter-tests branch Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment