From f7d516ed7b523031f14c21ec315a0e30989907d6 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 24 Jul 2021 00:35:04 -0700 Subject: [PATCH] [WebProfilerBundle] Use multi line comment --- .../views/Profiler/base_js.html.twig | 6 ++-- .../Tests/Resources/MinifyTest.php | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/MinifyTest.php diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig index e18700d15fc68..5ff45d44cbdca 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig @@ -748,7 +748,7 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') { return; } - // hide rows that don't match the current filters + /* hide rows that don't match the current filters */ let numVisibleRows = 0; logs.querySelectorAll('tbody tr').forEach((row) => { if ('all' !== selectedType && selectedType !== row.getAttribute('data-type')) { @@ -773,11 +773,11 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') { document.querySelector('table.logs').style.display = 0 === numVisibleRows ? 'none' : 'table'; document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none'; - // update the selected totals of all filters + /* update the selected totals of all filters */ document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length; document.querySelector('#log-filter-channel .filter-active-num').innerText = (channels.length === selectedChannels.length) ? 'All' : selectedChannels.length; - // update the currently selected "log type" tab + /* update the currently selected "log type" tab */ document.querySelectorAll('#log-filter-type li').forEach((tab) => tab.classList.remove('active')); document.querySelector(`#log-filter-type input[value="${selectedType}"]`).parentElement.classList.add('active'); }, diff --git a/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/MinifyTest.php b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/MinifyTest.php new file mode 100644 index 0000000000000..1eb0bac78361a --- /dev/null +++ b/src/Symfony/Bundle/WebProfilerBundle/Tests/Resources/MinifyTest.php @@ -0,0 +1,29 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources; + +use PHPUnit\Framework\TestCase; + +/** + * Make sure we can minify content in toolbar. + * @author Tobias Nyholm + */ +class MinifyTest extends TestCase +{ + public function testNoSingleLineComments() + { + $dir = dirname(__DIR__, 2).'/Resources/views/Profiler'; + $message = 'There cannot be any single line comment in this file. Consider using multiple line comment. '; + $this->assertTrue(2 === substr_count(file_get_contents($dir . '/base_js.html.twig'), '//'), $message); + $this->assertTrue(0 === substr_count(file_get_contents($dir.'/toolbar.css.twig'), '//'), $message); + } +}