Skip to content

[WebProfilerBundle] Fix the icon for the Cache panel #23160

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

Closed
wants to merge 8 commits into from

Conversation

javiereguiluz
Copy link
Member

Q A
Branch? 3.3
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #23159
License MIT
Doc PR -

@Hanmac
Copy link
Contributor

Hanmac commented Jun 13, 2017

hm i would add more attributes
that are the attributes of another icon:

<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="24" height="24" viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">

i think the other should be added to the cache icon too.

@stof
Copy link
Member

stof commented Jun 13, 2017

@javiereguiluz would it be worth writing a simple PHPUnit test enforcing the presence of these attributes in all SVG files of the icon folder ? It would forbid reintroducing the same bug each time we add a new panel.

@derrabus
Copy link
Member

This PR fixes the issue for me. Thanks a lot. :-)


namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources;

use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the PHPUnit class directly instead IMO. this base testcase is useless as it is empty

{
public function testIconFileContents()
{
$iconFiles = glob(__DIR__.'/../../Resources/views/Icon/*.svg');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving this glob to a data provider instead, so that all icon files are checked when running tests, instead of reporting only the first failed file

@stof
Copy link
Member

stof commented Jun 13, 2017

@javiereguiluz this PR should go in 3.3. Please change it to have a working CI (the master branch is currently broken)

@javiereguiluz javiereguiluz changed the base branch from master to 3.3 June 13, 2017 12:37
*/
public function testIconFileContents($iconFilePath)
{
$this->assertRegExp('/<svg version="1.1" xmlns="http:\/\/www.w3.org\/2000\/svg" x="0px" y="0px" width="\d+" height="\d+" viewBox="0 0 \d+ \d+" enable-background="new 0 0 \d+ \d+" xml:space="preserve">.*<\/svg>/s', file_get_contents($iconFilePath), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFilePath));
Copy link
Contributor

@ro0NL ro0NL Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using a different delimiter ({..} or my favorite ~...~ :)) so we dont need to escape / which occurs a few times :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh and please escape . :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey wouldn't a assertStringStartsWith be easier at this place?
i mean we only want to check the head of the file

Copy link
Contributor

@ro0NL ro0NL Jun 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we test this, lets test for a closing </svg> as well :) like currently. It doesnt hurt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hanmac yes, that would be easier and I used that at first ... but some icons have different sizes, so we can't use it :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz: okay now i understand why you use regexp.
hm but if we/you guys want to do that you could check if the width and hight does correspond to the viewBox

i was just thinking that we only need to check the head of the svg
hm should we also test if the svg is valid xml?

PS: we could also add xml declaration like this

<?xml version="1.0" encoding="utf-8"?>

or can't we do that because its embedded?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have the XML header in the icons and they look OK, so I guess it's optional to add it.

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Jun 14, 2017
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 (with @ro0NL comment applied if you agree also)

@javiereguiluz
Copy link
Member Author

I've made the requested changes.

@fabpot
Copy link
Member

fabpot commented Jun 16, 2017

Thank you @javiereguiluz.

fabpot added a commit that referenced this pull request Jun 16, 2017
…ereguiluz)

This PR was squashed before being merged into the 3.3 branch (closes #23160).

Discussion
----------

[WebProfilerBundle] Fix the icon for the Cache panel

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #23159
| License       | MIT
| Doc PR        | -

Commits
-------

50c1d47 [WebProfilerBundle] Fix the icon for the Cache panel
@fabpot fabpot closed this Jun 16, 2017
@Hanmac
Copy link
Contributor

Hanmac commented Jun 16, 2017

@javiereguiluz i think the xml Decl doesn't work because the svg are embedded? (don't know if my firefox does show it correct)
and it doesn't work with embedded

@fabpot fabpot mentioned this pull request Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants