-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
531 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
/** | ||
* Test: ConnectionPanel | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\Bridges\DatabaseTracy\ConnectionPanel; | ||
use Nette\Database\Connection; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
test('Tracy Bar', function () { | ||
$connection = new Connection('sqlite::memory:'); | ||
$panel = ConnectionPanel::initialize($connection, addBarPanel: true, name: 'foo'); | ||
|
||
$connection->beginTransaction(); | ||
$connection->query('SELECT 1'); | ||
$connection->commit(); | ||
try { | ||
$connection->query('SELECT'); | ||
} catch (Throwable) { | ||
} | ||
|
||
Assert::matchFile(__DIR__ . '/tab.html', $panel->getTab()); | ||
Assert::matchFile(__DIR__ . '/panel.html', $panel->getPanel()); | ||
}); | ||
|
||
test('Bluescreen Panel', function () { | ||
$connection = new Connection('sqlite::memory:'); | ||
try { | ||
$connection->query('SELECT'); | ||
} catch (Throwable $e) { | ||
} | ||
|
||
Assert::same( | ||
[ | ||
'tab' => 'SQL', | ||
'panel' => "<pre class=\"dump\"><strong style=\"color:blue\">SELECT</strong></pre>\n", | ||
], | ||
ConnectionPanel::renderException($e), | ||
); | ||
}); | ||
|
||
test('deprecated initialization', function () { | ||
$connection = new Connection('sqlite::memory:'); | ||
$panel = Nette\Database\Helpers::initializeTracy($connection, addBarPanel: true, name: 'foo'); | ||
|
||
$connection->beginTransaction(); | ||
$connection->query('SELECT 1'); | ||
$connection->commit(); | ||
try { | ||
$connection->query('SELECT'); | ||
} catch (Throwable) { | ||
} | ||
|
||
Assert::matchFile(__DIR__ . '/tab.html', $panel->getTab()); | ||
Assert::matchFile(__DIR__ . '/panel.html', $panel->getPanel()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
%A% | ||
<h1 title="sqlite::memory:">Queries: 4, time: %a% ms, foo</h1> | ||
|
||
<div class="tracy-inner"> | ||
<div class="tracy-inner-container"> | ||
<table class="tracy-sortable"> | ||
%A% | ||
<td %a%>%A%</td> | ||
<td class="nette-DbConnectionPanel-sql nette-DbConnectionPanel-sql-"><pre class="dump">::beginTransaction</pre> | ||
<a class="nette-DbConnectionPanel-source" href="%a%" title="%a%Connection.php:%d%" class="tracy-editor">%a%<b>Connection.php</b>:%d%</a> </td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td %a%>%A%</td> | ||
<td class="nette-DbConnectionPanel-sql nette-DbConnectionPanel-sql-select"><pre class="dump"><strong style="color:blue">SELECT</strong> 1</pre> | ||
<table class="tracy-collapsed nette-DbConnectionPanel-explain">%A%</table> | ||
<a class="nette-DbConnectionPanel-source" href="%a%" title="%a%Connection.php:%d%" class="tracy-editor">%a%<b>Connection.php</b>:%d%</a> </td> | ||
<td>0</td> | ||
</tr> | ||
<tr> | ||
<td %a%>%A%</td> | ||
<td class="nette-DbConnectionPanel-sql nette-DbConnectionPanel-sql-"><pre class="dump">::commit</pre> | ||
<a class="nette-DbConnectionPanel-source" href="%a%" title="%a%Connection.php:%d%" class="tracy-editor">%a%<b>Connection.php</b>:%d%</a> </td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td %a%> | ||
<span title="SQLSTATE[HY000]: %a%">ERROR</span> | ||
</td> | ||
<td class="nette-DbConnectionPanel-sql nette-DbConnectionPanel-sql-"><pre class="dump"><strong style="color:blue">SELECT</strong></pre> | ||
<a class="nette-DbConnectionPanel-source" href="%a%" title="%a%SqliteDriver.php:%d%" class="tracy-editor">%a%<b>SqliteDriver.php</b>:%d%</a> </td> | ||
<td></td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<span title="Nette\Database foo"> | ||
<svg %A%</svg><span class="tracy-label">%a% ms / 4</span> | ||
</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.