Thanks to visit codestin.com
Credit goes to github.com

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
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improved the test
  • Loading branch information
javiereguiluz committed Jun 13, 2017
commit 97fe4b152782ced8decf7ccb5a0ad2a206380db4
20 changes: 14 additions & 6 deletions src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/IconTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@

namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources;

use Symfony\Bundle\WebProfilerBundle\Tests\TestCase;
use PHPUnit\Framework\TestCase;

class IconTest extends TestCase
{
public function testIconFileContents()
/**
* @dataProvider provideIconFilePaths
*/
public function testIconFileContents($iconFilePath)
{
$iconFiles = glob(__DIR__.'/../../Resources/views/Icon/*.svg');
foreach ($iconFiles as $iconFile) {
$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($iconFile), sprintf('The SVG metadata of the %s icon is different than expected (use the same as the other icons).', $iconFile));
}
$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.

}

public function provideIconFilePaths()
{
return array_map(
function ($filePath) { return (array) $filePath; },
glob(__DIR__.'/../../Resources/views/Icon/*.svg')
);
}
}