Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9d53f00

Browse filesBrowse files
committed
[WebProfilerBundle] added HTTP status code column to search results
1 parent 607b110 commit 9d53f00
Copy full SHA for 9d53f00

File tree

Expand file treeCollapse file tree

4 files changed

+87
-0
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+87
-0
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
2.7.0
5+
-----
6+
7+
* [BC BREAK] if you are using a DB to store profiles, the table must be dropped
8+
* added the HTTP status code to profiles
9+
410
2.3.0
511
-----
612

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/results.html.twig
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<th scope="col">Method</th>
1313
<th scope="col">URL</th>
1414
<th scope="col">Time</th>
15+
<th scope="col">Status</th>
1516
</tr>
1617
</thead>
1718
<tbody>
@@ -22,6 +23,13 @@
2223
<td>{{ elements.method }}</td>
2324
<td>{{ elements.url }}</td>
2425
<td>{{ elements.time|date('r') }}</td>
26+
<td>
27+
{% if elements.status_code is defined and elements.status_code %}
28+
<abbr title="{{ http_status_text(elements.status_code, 'unknown') }}">{{ elements.status_code }}</abbr>
29+
{% else %}
30+
unknown
31+
{% endif %}
32+
</td>
2533
</tr>
2634
{% endfor %}
2735
</tbody>

‎src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Tests/Controller/ProfilerControllerTest.php
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,66 @@ public function testReturns404onTokenNotFound()
7373
$response = $controller->toolbarAction(Request::create('/_wdt/notFound'), 'notFound');
7474
$this->assertEquals(404, $response->getStatusCode());
7575
}
76+
77+
public function testSearchResult()
78+
{
79+
$urlGenerator = $this->getMock('Symfony\Component\Routing\Generator\UrlGeneratorInterface');
80+
$twig = $this->getMock('Twig_Environment');
81+
$profiler = $this
82+
->getMockBuilder('Symfony\Component\HttpKernel\Profiler\Profiler')
83+
->disableOriginalConstructor()
84+
->getMock();
85+
86+
$controller = new ProfilerController($urlGenerator, $profiler, $twig, array());
87+
88+
$tokens = array(
89+
array(
90+
'token' => 'token1',
91+
'ip' => '127.0.0.1',
92+
'method' => 'GET',
93+
'url' => 'http://example.com/',
94+
'time' => 0,
95+
'parent' => null,
96+
'status_code' => 200,
97+
),
98+
array(
99+
'token' => 'token2',
100+
'ip' => '127.0.0.1',
101+
'method' => 'GET',
102+
'url' => 'http://example.com/not_found',
103+
'time' => 0,
104+
'parent' => null,
105+
'status_code' => 404,
106+
),
107+
);
108+
$profiler
109+
->expects($this->once())
110+
->method('find')
111+
->will($this->returnValue($tokens));
112+
113+
$twig->expects($this->once())
114+
->method('render')
115+
->with($this->stringEndsWith('results.html.twig'), $this->equalTo(array(
116+
'token' => 'empty',
117+
'profile' => null,
118+
'tokens' => $tokens,
119+
'ip' => '127.0.0.1',
120+
'method' => 'GET',
121+
'url' => 'http://example.com/',
122+
'start' => null,
123+
'end' => null,
124+
'limit' => 2,
125+
'panel' => null,
126+
)));
127+
128+
$response = $controller->searchResultsAction(
129+
Request::create(
130+
'/_profiler/empty/search/results',
131+
'GET',
132+
array('limit' => 2, 'ip' => '127.0.0.1', 'method' => 'GET', 'url' => 'http://example.com/')
133+
),
134+
'empty'
135+
);
136+
$this->assertEquals(200, $response->getStatusCode());
137+
}
76138
}

‎src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\WebProfilerBundle\Twig;
1313

14+
use Symfony\Component\HttpFoundation\Response;
1415
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;
1516

1617
/**
@@ -32,6 +33,7 @@ public function getFunctions()
3233
{
3334
return array(
3435
new \Twig_SimpleFunction('profiler_dump', array($this, 'dumpValue')),
36+
new \Twig_SimpleFunction('http_status_text', array($this, 'httpStatusText')),
3537
);
3638
}
3739

@@ -44,6 +46,15 @@ public function dumpValue($value)
4446
return $this->valueExporter->exportValue($value);
4547
}
4648

49+
public function httpStatusText($statusCode, $fallback)
50+
{
51+
if (isset(Response::$statusTexts[$statusCode])) {
52+
return Response::$statusTexts[$statusCode];
53+
}
54+
55+
return $fallback;
56+
}
57+
4758
/**
4859
* {@inheritdoc}
4960
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.