Skip to content

Commit 5ef7c1b

Browse files
committed
Add failing test for custom array prototype
1 parent ed9a305 commit 5ef7c1b

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

tests/DebugbarBrowserTest.php

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,22 @@ protected function addWebRoutes(Router $router)
6868
}
6969
]);
7070

71+
$router->get('web/custom-prototype', [
72+
'uses' => function () {
73+
74+
/** @var Connection $connection */
75+
$connection = $this->app['db']->connectUsing(
76+
'runtime-connection',
77+
[
78+
'driver' => 'sqlite',
79+
'database' => ':memory:',
80+
],
81+
);
82+
event(new QueryExecuted('SELECT * FROM users WHERE username = ?', ['debuguser'], 0, $connection));
83+
return view('custom-prototype');
84+
}
85+
]);
86+
7187
$router->get('web/query/{num?}', [
7288
'uses' => function ($num = 1) {
7389
debugbar()->boot();
@@ -85,7 +101,6 @@ protected function addWebRoutes(Router $router)
85101
$executedQuery = new QueryExecuted('SELECT * FROM users WHERE username = ?', ['debuguser' . $i], 0, $connection);
86102
event($executedQuery);
87103
}
88-
89104
return 'PONG';
90105
}
91106
]);
@@ -201,6 +216,32 @@ public function testDatabaseCollectsQueries()
201216
});
202217
}
203218

219+
public function testDatabaseCollectsQueriesWithCustomPrototype()
220+
{
221+
if (version_compare($this->app->version(), '10', '<')) {
222+
$this->markTestSkipped('This test is not compatible with Laravel 9.x and below');
223+
}
224+
225+
$this->browse(function (Browser $browser) {
226+
$browser->visit('web/custom-prototype')
227+
->waitFor('.phpdebugbar')
228+
->click('.phpdebugbar-tab-history')
229+
->waitForTextIn('.phpdebugbar-tab[data-collector="queries"] .phpdebugbar-badge', 1)
230+
->click('.phpdebugbar-tab[data-collector="queries"]')
231+
->screenshotElement('.phpdebugbar', 'queries-tab')
232+
->waitForText('executed')
233+
->assertSee('1 statement was executed')
234+
->with('.phpdebugbar-widgets-sqlqueries', function ($queriesPane) {
235+
$queriesPane->assertSee('SELECT * FROM users')
236+
->click('.phpdebugbar-widgets-expandable:nth-child(2)')
237+
->assertSee('Bindings')
238+
->assertSee('debuguser')
239+
->assertSee('Backtrace')
240+
->assertSee('LaravelDebugbar.php:');
241+
})
242+
->screenshotElement('.phpdebugbar', 'queries-expanded');
243+
});
244+
}
204245

205246
public function testDatabaseCollectsQueriesWithSoftLimit()
206247
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<body>
3+
4+
<script>
5+
Array.prototype.customRemove = function(item) {
6+
const i = this.indexOf(item)
7+
if (i > -1) {
8+
this.splice(i, 1)
9+
}
10+
return this
11+
}
12+
</script>
13+
</body>

0 commit comments

Comments
 (0)