-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New tests, TagArrayToStringTransformer #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 if possible, please add a test condition for the usual mistake of adding too many commas (or empty tags). Example: Hello, Demo,, How
and Hello, Demo, How,
@javiereguiluz the array_map, array_filter, explode is getting out of control, how would you improve the readability of this ? I wanted to avoid Intermediary variables :( |
@Grafikart |
Nice tip indeed |
} | ||
|
||
/** | ||
* Spaces at the end (and begining) of a world shouldn't matter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beginning
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -54,7 +54,7 @@ public function reverseTransform($string) | |||
return []; | |||
} | |||
|
|||
$names = explode(',', $string); | |||
$names = array_filter(array_unique(array_map('trim', explode(',', $string)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tagsinput plugins itself does not allows duplicated, empty tags, extra spaces, double comma (on client side), BUT it could be hacked :) so I'm 👍 to check this on server side as double validation. Maybe I would add strtolower
also to keep consistency with current ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about strtolower, for instance I want my "JavaScript", "WordPress" tags to keep the upcases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could still add this transformation within the constructor
public function __construct(ObjectManager $manager, $forceStrToLower = false)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep things simple and let's not add the $forceStrToLower
option.
*/ | ||
public function testUsesAlreadyDefinedTags() | ||
{ | ||
$persisted_tags = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use camelCase, not underscores, for variable :) (Ref.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, linter didn't caught this one ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with the next commit
@@ -0,0 +1,117 @@ | |||
<?php | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing license docblock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed with the next commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* | ||
* See http://symfony.com/doc/current/testing/database.html | ||
* | ||
* @author Jonathan Boyer <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@author
AFAIK it's not common in tests classes, instead you can move it to TagArrayToStringTransformer
class ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right misinterpreted the last review :) fixing it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the link should stay here to explain how mocks work. I remove the @author only right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right.
Symfony policy is to *not* add the authors in test files. Personally I don't agree ... but in this repo we must follow the Symfony practices. That's why I removed you from here ... but I added you in the PHP class associated with this test.
* Moved the helper methods at the end of the file and made them `private` * Minor changes to match the code style of the other tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It's merged now! Thanks @Grafikart for your contribution! |
…reguiluz) This PR was merged into the master branch. Discussion ---------- New tests, TagArrayToStringTransformer Added some tests to demonstrate how to mock a Repository and test things without the database Commits ------- ae2391f Fixed code syntax issue reported by Travis CI 15a8d39 Minor changes 0f14c57 Added the missing license header and removed the author info 75734c6 Added Jonathan to the list of authors e3ab52c Fixed more typos b596f77 Fixed typo 72a0f85 Simplified code 3e891f5 Created a new case f69514a Merge remote-tracking branch 'origin/tag-test' into tag-test 2ca2e9b Fixed some typos 55d5bb4 Simplified some code a8de079 New tests, TagArrayToStringTransformer
Added some tests to demonstrate how to mock a Repository and test things without the database