Test collect real path from compiled views on QueryCollector (#1543)

Co-authored-by: Lars <lars.dobschall@eigens.net>
This commit is contained in:
erikn69 2024-02-22 09:07:41 -05:00 committed by GitHub
parent 950695096c
commit 47f25f2cd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 0 deletions

View File

@ -59,4 +59,30 @@ SQL
);
});
}
public function testFindingCorrectPathForView()
{
debugbar()->boot();
/** @var \Barryvdh\Debugbar\DataCollector\QueryCollector $collector */
$collector = debugbar()->getCollector('queries');
view('query')
->with('db', $this->app['db']->connection())
->with('collector', $collector)
->render();
tap(Arr::first($collector->collect()['statements']), function (array $statement) {
$this->assertEquals(
"SELECT a FROM b WHERE c = '$10' AND d = '$2y$10_DUMMY_BCRYPT_HASH' AND e = '\$_$\$_$$\$_$2_$3'",
$statement['sql']
);
$this->assertTrue(@file_exists($statement['backtrace'][1]->file));
$this->assertEquals(
realpath(__DIR__ . '/../resources/views/query.blade.php'),
realpath($statement['backtrace'][1]->file)
);
});
}
}

View File

@ -0,0 +1,8 @@
@php
$collector->addQuery(new \Illuminate\Database\Events\QueryExecuted(
"SELECT a FROM b WHERE c = ? AND d = ? AND e = ?",
['$10', '$2y$10_DUMMY_BCRYPT_HASH', '$_$$_$$$_$2_$3'],
0,
$db
));
@endphp