diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a96e59..03314f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ All notable changes to `phalcon/debugbar` are documented here. The format is bas - Request history does not set its cookie when output started before the response, so `setcookie()` gives no warning. [#32](https://github.com/phalcon/debugbar/issues/32) - `history.url` cannot be `/`. The documentation states that the history endpoint wins over an application route with the same path, for each HTTP method. [#32](https://github.com/phalcon/debugbar/issues/32) - The documentation states that a browser in request history is one history cookie, so all its windows and tabs count as one for `history.max_browsers`. [#32](https://github.com/phalcon/debugbar/issues/32) +- The debug page exceptions implement `Phalcon\Debug\Contracts\DebugThrowable`. [#95](https://github.com/phalcon/debugbar/issues/95) ### Changed @@ -91,6 +92,10 @@ All notable changes to `phalcon/debugbar` are documented here. The format is bas - Share one renderer and one CSS block for the exceptions and logs panels, and show an exception with no trace as a plain line. [#108](https://github.com/phalcon/debugbar/issues/108) - Test HTML writes, the collapse state and `localStorage` errors in the JS tests, and keep every listener in the fake DOM. [#103](https://github.com/phalcon/debugbar/issues/103) +### Removed + +- `HistoryController::clearAction()` and `indexAction()`, `Phalcon\DebugBar\Version` and `CodeFragment::getMode()`, which nothing used. [#95](https://github.com/phalcon/debugbar/issues/95) + ## [0.4.0](https://github.com/phalcon/debugbar/releases/tag/v0.4.0) (2026-07-14) ### Changed diff --git a/docs/index.md b/docs/index.md index f98dffb..f7573e5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -40,7 +40,7 @@ use Phalcon\Debug; `listen()` does not see the exceptions of an ADR application, because the application catches them first. For an ADR application, see [ADR](#adr). -The page escapes every value it shows, including quotes, the class name and file paths. A byte that is not valid UTF-8 shows as `�` (U+FFFD), so the rest of the message still shows. A frame from `eval()`'d code, or from a file that cannot be read, shows no source lines. An exception that occurs while the page renders shows only its escaped message. `Phalcon\Debug\Dump` prints `*RECURSION*` for an object or an array that contains itself, and `[uninitialized]` for a typed property that has no value yet. To show an object, the page calls its `dump()` method only if that method is public, is not static, and has no required parameters. `setBlacklist()` removes a matching key at every depth, so `user[password]` does not show. The page discards each output buffer that starts after `Debug` is created, so create it before the application starts its own buffers. Under the message, the page shows each previous exception (`getPrevious()`) with its class, message, file and line. A framework class links to its API page on docs.phalcon.io for the Phalcon version that runs. `debugVar()` keeps the backtrace frames, but not their arguments and objects. +The page escapes every value it shows, including quotes, the class name and file paths. A byte that is not valid UTF-8 shows as `�` (U+FFFD), so the rest of the message still shows. A frame from `eval()`'d code, or from a file that cannot be read, shows no source lines. An exception that occurs while the page renders shows only its escaped message. `Phalcon\Debug\Dump` prints `*RECURSION*` for an object or an array that contains itself, and `[uninitialized]` for a typed property that has no value yet. To show an object, the page calls its `dump()` method only if that method is public, is not static, and has no required parameters. `setBlacklist()` removes a matching key at every depth, so `user[password]` does not show. The page discards each output buffer that starts after `Debug` is created, so create it before the application starts its own buffers. Under the message, the page shows each previous exception (`getPrevious()`) with its class, message, file and line. A framework class links to its API page on docs.phalcon.io for the Phalcon version that runs. `debugVar()` keeps the backtrace frames, but not their arguments and objects. Each exception of the debug page (`Exceptions\Exception`, `Exceptions\RequestHalted`, `Exceptions\RuntimeWarning`) implements `Phalcon\Debug\Contracts\DebugThrowable`, so one `catch` covers all of them. The remainder of this document covers the debug bar. diff --git a/resources/assets/debug.css b/resources/assets/debug.css index 9b51cd1..0f643c5 100644 --- a/resources/assets/debug.css +++ b/resources/assets/debug.css @@ -79,7 +79,6 @@ body { align-items: center; gap: 7px; font-size: 13px; } .btn:hover { color: var(--ink); border-color: var(--faint); } -.btn svg { opacity: .8; } .version-badge { font-size: 12px; color: var(--muted); background: var(--chip); border: 1px solid var(--border); padding: 6px 11px; border-radius: 999px; text-decoration: none; @@ -134,9 +133,6 @@ body { .frame-call .cls a:hover { text-decoration: underline; } .frame-call .op { color: var(--faint); } .frame-call .fn { color: var(--ink); font-weight: 650; } -.frame-call .arg-str { color: var(--ok); } -.frame-call .arg-num { color: #b25000; } -html[data-theme="dark"] .frame-call .arg-num { color: #ff9e64; } .frame.vendor .frame-call .fn { color: var(--muted); font-weight: 550; } .tag-app { font-size: 9px; font-weight: 700; letter-spacing: .4px; color: var(--ok); text-transform: uppercase; @@ -196,11 +192,6 @@ html[data-theme="dark"] .frame-call .arg-num { color: #ff9e64; } .grid tr:hover td { background: var(--panel-2); } .grid .k { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; width: 1%; } .grid .v { font-family: var(--mono); font-size: 12px; word-break: break-word; } -.grid .v .t-str { color: var(--ok); } -.grid .v .t-num { color: #b25000; } -.grid .v .t-obj { color: #8250df; } -html[data-theme="dark"] .grid .v .t-num { color: #ff9e64; } -html[data-theme="dark"] .grid .v .t-obj { color: #d2a8ff; } /* memory stats */ .stats { display: flex; gap: 14px; flex-wrap: wrap; } diff --git a/resources/assets/debug.js b/resources/assets/debug.js index f543dc8..ba610b0 100644 --- a/resources/assets/debug.js +++ b/resources/assets/debug.js @@ -69,7 +69,7 @@ var cell = cells[i]; if (cell.getAttribute("data-hl")) { continue; } var text = cell.textContent; - if (text.replace(/ /g, " ").trim() !== "") { + if (text.trim() !== "") { cell.innerHTML = highlightPhp(text); } cell.setAttribute("data-hl", "1"); diff --git a/resources/assets/debugbar.js b/resources/assets/debugbar.js index e3e6ee3..a449ea8 100644 --- a/resources/assets/debugbar.js +++ b/resources/assets/debugbar.js @@ -647,8 +647,9 @@ return; } - var data = payload.data || {}; - var widgets = (payload.meta && payload.meta.widgets) || {}; + // renderData() sets both before any panel reads them. + var data; + var widgets; var bar = el('div', 'phalcon-debugbar-bar'); var historyBrowser = el('div', 'phalcon-debugbar-history-browser'); @@ -775,9 +776,9 @@ } function renderData(nextPayload, preferredActive, requestMetadata) { - payload = nextPayload || {}; - data = payload.data || {}; - widgets = (payload.meta && payload.meta.widgets) || {}; + var current = nextPayload || {}; + data = current.data || {}; + widgets = (current.meta && current.meta.widgets) || {}; tabs.innerHTML = ''; body.innerHTML = ''; body.style.display = 'none'; diff --git a/resources/assets/debugbar.min.js b/resources/assets/debugbar.min.js index 19b840f..4eec0cd 100644 --- a/resources/assets/debugbar.min.js +++ b/resources/assets/debugbar.min.js @@ -73,7 +73,7 @@ if(typeof document==='undefined'){if(typeof module!=='undefined'&&module.exports return} ready(function(){var dataNode=document.getElementById('phalcon-debugbar-data');var mount=document.getElementById('phalcon-debugbar');if(!dataNode||!mount){return} var payload;try{payload=JSON.parse(dataNode.textContent)}catch(error){return} -var data=payload.data||{};var widgets=(payload.meta&&payload.meta.widgets)||{};var bar=el('div','phalcon-debugbar-bar');var historyBrowser=el('div','phalcon-debugbar-history-browser');var body=el('div','phalcon-debugbar-body');var row=el('div','phalcon-debugbar-row');var tabs=el('div','phalcon-debugbar-tabs');tabs.setAttribute('role','tablist');var indicators=el('div','phalcon-debugbar-indicators');var toggle=el('button','phalcon-debugbar-toggle','⚡');toggle.type='button';toggle.title='Toggle Phalcon DebugBar';toggle.setAttribute('aria-label','Toggle Phalcon DebugBar');body.style.display='none';var active=null;var selectedHistoryId='';var historyOpen=!1;var historyPanel=null;var historyRenderGeneration=0;var historyTrigger=null;var activeBeforeHistory=null;function setSelected(node,selected){node.classList.toggle('is-active',selected);if(node.getAttribute('role')==='tab'){node.setAttribute('aria-selected',selected?'true':'false')}} +var data;var widgets;var bar=el('div','phalcon-debugbar-bar');var historyBrowser=el('div','phalcon-debugbar-history-browser');var body=el('div','phalcon-debugbar-body');var row=el('div','phalcon-debugbar-row');var tabs=el('div','phalcon-debugbar-tabs');tabs.setAttribute('role','tablist');var indicators=el('div','phalcon-debugbar-indicators');var toggle=el('button','phalcon-debugbar-toggle','⚡');toggle.type='button';toggle.title='Toggle Phalcon DebugBar';toggle.setAttribute('aria-label','Toggle Phalcon DebugBar');body.style.display='none';var active=null;var selectedHistoryId='';var historyOpen=!1;var historyPanel=null;var historyRenderGeneration=0;var historyTrigger=null;var activeBeforeHistory=null;function setSelected(node,selected){node.classList.toggle('is-active',selected);if(node.getAttribute('role')==='tab'){node.setAttribute('aria-selected',selected?'true':'false')}} function closePanel(){body.style.display='none';active=null;Array.prototype.forEach.call(row.querySelectorAll('[data-panel-tab]'),function(child){setSelected(child,!1)})} function renderOpenHistory(){if(!historyOpen||!historyPanel){historyBrowser.style.display='none';return} var generation=++historyRenderGeneration;renderHistoryBrowser(historyBrowser,{panel:historyPanel,selectedId:selectedHistoryId,onSelect:function(storedPayload,storedMetadata,id){var preferredActive=activeBeforeHistory;selectedHistoryId=id;setHistoryOpen(!1);activeBeforeHistory=null;renderData(storedPayload,preferredActive,storedMetadata)},onClear:function(){selectedHistoryId=''},isCurrent:function(){return historyOpen&&generation===historyRenderGeneration}})} @@ -84,7 +84,7 @@ toggle.setAttribute('aria-expanded',collapsed?'false':'true')} toggle.addEventListener('click',function(){var collapsed=!mount.classList.contains('is-collapsed');setCollapsed(collapsed);writeCollapsed(collapsed)});mount.addEventListener('keydown',function(event){if(event.key!=='Escape'){return} if(historyOpen){setHistoryOpen(!1)}else if(active!==null){closePanel()}});function activate(name,tab,entry,type){closePanel();setHistoryOpen(!1);setSelected(tab,!0);body.innerHTML='';var summary=renderSummary(entry.summary);if(summary){body.appendChild(summary)} body.appendChild(renderPanel(type,entry.panel));body.style.display='block';active=name} -function renderData(nextPayload,preferredActive,requestMetadata){payload=nextPayload||{};data=payload.data||{};widgets=(payload.meta&&payload.meta.widgets)||{};tabs.innerHTML='';body.innerHTML='';body.style.display='none';active=null;var historyName=Object.keys(widgets).find(function(name){return widgets[name]&&widgets[name].panel==='history'});var historyEntry=historyName?(data[historyName]||{}):{};historyPanel=null;if(historyEntry.panel&&typeof historyEntry.panel.url==='string'){historyPanel=historyEntry.panel}else{historyOpen=!1} +function renderData(nextPayload,preferredActive,requestMetadata){var current=nextPayload||{};data=current.data||{};widgets=(current.meta&¤t.meta.widgets)||{};tabs.innerHTML='';body.innerHTML='';body.style.display='none';active=null;var historyName=Object.keys(widgets).find(function(name){return widgets[name]&&widgets[name].panel==='history'});var historyEntry=historyName?(data[historyName]||{}):{};historyPanel=null;if(historyEntry.panel&&typeof historyEntry.panel.url==='string'){historyPanel=historyEntry.panel}else{historyOpen=!1} var preferred=null;function bindPanel(name,node){var entry=data[name]||{};var widget=widgets[name]||{};var type=widget.panel||inferType(entry.panel);node.setAttribute('data-panel-tab',name);node.addEventListener('click',function(){setHistoryOpen(!1);if(active===name){closePanel();return} activate(name,node,entry,type)});if(name===preferredActive){preferred=[name,node,entry,type]}} Object.keys(data).forEach(function(name){var entry=data[name]||{};var widget=widgets[name]||{};if(widget.panel==='history'||widget.indicator){return} diff --git a/src/Debug/Contracts/DebugThrowable.php b/src/Debug/Contracts/DebugThrowable.php index b73e97f..d84f1a4 100644 --- a/src/Debug/Contracts/DebugThrowable.php +++ b/src/Debug/Contracts/DebugThrowable.php @@ -16,8 +16,9 @@ use Throwable as BaseThrowable; /** - * Catch-all marker implemented by every exception this package throws, so - * integrators can catch `Throwable` to trap anything from the bar. + * Catch-all marker implemented by every exception of the debug page + * (`Phalcon\Debug`), so integrators can catch `DebugThrowable` to trap + * anything from it. */ interface DebugThrowable extends BaseThrowable { diff --git a/src/Debug/Exceptions/Exception.php b/src/Debug/Exceptions/Exception.php index 28d4c2a..99500ba 100644 --- a/src/Debug/Exceptions/Exception.php +++ b/src/Debug/Exceptions/Exception.php @@ -13,11 +13,12 @@ namespace Phalcon\Debug\Exceptions; +use Phalcon\Debug\Contracts\DebugThrowable; use Phalcon\Support\Exception as SupportException; /** * Exceptions thrown in Phalcon\Debug will use this class */ -class Exception extends SupportException +class Exception extends SupportException implements DebugThrowable { } diff --git a/src/Debug/Exceptions/RuntimeWarning.php b/src/Debug/Exceptions/RuntimeWarning.php index 7081d7a..3dcf7df 100644 --- a/src/Debug/Exceptions/RuntimeWarning.php +++ b/src/Debug/Exceptions/RuntimeWarning.php @@ -13,6 +13,8 @@ namespace Phalcon\Debug\Exceptions; -class RuntimeWarning extends \ErrorException +use Phalcon\Debug\Contracts\DebugThrowable; + +class RuntimeWarning extends \ErrorException implements DebugThrowable { } diff --git a/src/Debug/Report/CodeFragment.php b/src/Debug/Report/CodeFragment.php index b477480..85b8b92 100644 --- a/src/Debug/Report/CodeFragment.php +++ b/src/Debug/Report/CodeFragment.php @@ -23,7 +23,6 @@ final class CodeFragment * @param array $lines */ public function __construct( - private readonly string $mode, private readonly int $firstLine, private readonly int $line, private readonly int $lastLine, @@ -53,9 +52,4 @@ public function getLines(): array { return $this->lines; } - - public function getMode(): string - { - return $this->mode; - } } diff --git a/src/Debug/ReportBuilder.php b/src/Debug/ReportBuilder.php index b5f8569..affe645 100644 --- a/src/Debug/ReportBuilder.php +++ b/src/Debug/ReportBuilder.php @@ -136,14 +136,12 @@ private function buildFragment(string $file, int $line, bool $showFileFragment): $firstLine = ($beforeLine < 1) ? 1 : $beforeLine; $afterLine = $line + 5; $lastLine = ($afterLine > $numberLines) ? $numberLines : $afterLine; - $mode = 'fragment'; } else { $firstLine = 1; $lastLine = $numberLines; - $mode = 'full'; } - return new CodeFragment($mode, $firstLine, $line, $lastLine, $lines); + return new CodeFragment($firstLine, $line, $lastLine, $lines); } /** diff --git a/src/DebugBar/Controllers/HistoryController.php b/src/DebugBar/Controllers/HistoryController.php index f1c7743..1b8f59d 100644 --- a/src/DebugBar/Controllers/HistoryController.php +++ b/src/DebugBar/Controllers/HistoryController.php @@ -40,16 +40,6 @@ public function __construct( $this->handler = new HistoryHandler($history, $accessGate, $historyRequest, $historyResponse); } - public function clearAction(): ResponseInterface - { - return $this->handler->clear(); - } - - public function indexAction(): ResponseInterface - { - return $this->handler->index(); - } - public function openAction(): ResponseInterface { return $this->handler->open(); diff --git a/src/DebugBar/History/FilesystemHistory.php b/src/DebugBar/History/FilesystemHistory.php index f215c77..e2a7f52 100644 --- a/src/DebugBar/History/FilesystemHistory.php +++ b/src/DebugBar/History/FilesystemHistory.php @@ -150,7 +150,7 @@ public function get(string $id): ?array if (null === $directory) { return null; } - $file = $directory . '/' . basename($id) . '.json'; + $file = $directory . '/' . $id . '.json'; if ($this->isExpired($file)) { $this->removeEntry($file); $this->removeDirectoryIfEmpty($directory); diff --git a/src/DebugBar/Version.php b/src/DebugBar/Version.php deleted file mode 100644 index 9283f65..0000000 --- a/src/DebugBar/Version.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\DebugBar; - -/** - * Exposes the debug bar package version. - */ -final class Version -{ - private const VERSION = '0.1.0'; - - public function get(): string - { - return self::VERSION; - } -} diff --git a/tests/Unit/Debug/Contracts/DebugThrowableTest.php b/tests/Unit/Debug/Contracts/DebugThrowableTest.php new file mode 100644 index 0000000..4b11ccf --- /dev/null +++ b/tests/Unit/Debug/Contracts/DebugThrowableTest.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Tests\Unit\Debug\Contracts; + +use Phalcon\Debug\Contracts\DebugThrowable; +use Phalcon\Debug\Exceptions\Exception; +use Phalcon\Debug\Exceptions\RequestHalted; +use Phalcon\Debug\Exceptions\RuntimeWarning; +use Phalcon\Talon\PHPUnit\AbstractUnitTestCase; +use PHPUnit\Framework\Attributes\DataProvider; +use Throwable; + +final class DebugThrowableTest extends AbstractUnitTestCase +{ + /** + * @return array + */ + public static function throwableProvider(): array + { + return [ + 'Exception' => [new Exception('failed')], + 'RequestHalted' => [new RequestHalted()], + 'RuntimeWarning' => [new RuntimeWarning('warning')], + ]; + } + + #[DataProvider('throwableProvider')] + public function testEachDebugPageExceptionIsADebugThrowable(Throwable $throwable): void + { + $this->assertInstanceOf(DebugThrowable::class, $throwable); + } +} diff --git a/tests/Unit/Debug/Renderer/HtmlRendererTest.php b/tests/Unit/Debug/Renderer/HtmlRendererTest.php index 1d8d807..16872ab 100644 --- a/tests/Unit/Debug/Renderer/HtmlRendererTest.php +++ b/tests/Unit/Debug/Renderer/HtmlRendererTest.php @@ -250,7 +250,7 @@ public function testRenderReplacesInvalidUtf8InASourceLine(): void [], '/app/x.php', 1, - new CodeFragment('fragment', 1, 1, 1, ["\$name = 'caf\xE9';\n"]) + new CodeFragment(1, 1, 1, ["\$name = 'caf\xE9';\n"]) ), ] ); @@ -370,7 +370,6 @@ public function testTemplatesFallThrough(): void private function buildReport(): ExceptionReport { $fragment = new CodeFragment( - 'fragment', 3, 4, 5, diff --git a/tests/Unit/Debug/Report/BacktraceItemTest.php b/tests/Unit/Debug/Report/BacktraceItemTest.php index 5e497fb..f35e707 100644 --- a/tests/Unit/Debug/Report/BacktraceItemTest.php +++ b/tests/Unit/Debug/Report/BacktraceItemTest.php @@ -32,7 +32,7 @@ public function testDefaultsForMinimalFrame(): void public function testGettersReturnConstructorValues(): void { - $fragment = new CodeFragment('full', 1, 4, 9, ["assertSame('fragment', $fragment->getMode()); $this->assertSame(3, $fragment->getFirstLine()); $this->assertSame(5, $fragment->getLine()); $this->assertSame(9, $fragment->getLastLine()); diff --git a/tests/Unit/Debug/ReportBuilderTest.php b/tests/Unit/Debug/ReportBuilderTest.php index 93f9317..911d868 100644 --- a/tests/Unit/Debug/ReportBuilderTest.php +++ b/tests/Unit/Debug/ReportBuilderTest.php @@ -202,7 +202,6 @@ public function testFragmentModeFragment(): void /** @var CodeFragment $fragment */ $fragment = $method->invoke($builder, $file, 20, true); - $this->assertSame('fragment', $fragment->getMode()); $this->assertSame(13, $fragment->getFirstLine()); $this->assertSame(20, $fragment->getLine()); $this->assertSame(25, $fragment->getLastLine()); @@ -219,7 +218,6 @@ public function testFragmentModeFull(): void /** @var CodeFragment $fragment */ $fragment = $method->invoke($builder, $file, 20, false); - $this->assertSame('full', $fragment->getMode()); $this->assertSame(1, $fragment->getFirstLine()); $this->assertSame(20, $fragment->getLine()); $this->assertSame(30, $fragment->getLastLine()); diff --git a/tests/Unit/DebugBar/Controllers/HistoryControllerTest.php b/tests/Unit/DebugBar/Controllers/HistoryControllerTest.php index 314cf93..54fdf9f 100644 --- a/tests/Unit/DebugBar/Controllers/HistoryControllerTest.php +++ b/tests/Unit/DebugBar/Controllers/HistoryControllerTest.php @@ -48,9 +48,9 @@ public function testActionsHideHistoryWhenAccessIsDenied(): void $_SERVER['REMOTE_ADDR'] = '203.0.113.10'; $history = new FilesystemHistory(new HistoryOptions()); - foreach (['indexAction', 'clearAction'] as $action) { - $response = $this->executeWithServices( - $action, + foreach (['GET', 'DELETE'] as $method) { + $_SERVER['REQUEST_METHOD'] = $method; + $response = $this->executeWithServices( new Request(), new Response(), $history, @@ -65,10 +65,9 @@ public function testActionsRejectUnsupportedMethods(): void { $history = new FilesystemHistory(new HistoryOptions()); - foreach ([['indexAction', 'POST'], ['clearAction', 'GET']] as [$action, $method]) { + foreach (['POST', 'PUT'] as $method) { $_SERVER['REQUEST_METHOD'] = $method; $response = $this->executeWithServices( - $action, new Request(), new Response(), $history, @@ -109,7 +108,6 @@ public function testInvalidStoredRequestIdentifierReturnsNotFound(): void foreach (['', ['invalid']] as $id) { $_GET = ['id' => $id]; $response = $this->executeWithServices( - 'indexAction', new Request(), new Response(), new FilesystemHistory(new HistoryOptions()), @@ -162,7 +160,7 @@ public function testListsAndLoadsRequestsFromTheCurrentBrowser(): void $_SERVER['REQUEST_METHOD'] = 'DELETE'; $_GET = []; - $clear = $this->execute($history, 'clear'); + $clear = $this->execute($history); $this->assertSame(200, $clear->getStatusCode()); $clearBody = json_decode($clear->getContent(), true); $this->assertIsArray($clearBody); @@ -220,7 +218,6 @@ public function testMissingStoredRequestReturnsNotFound(): void $_GET = ['id' => '20260903120000-123456-deadbeef']; $response = $this->executeWithServices( - 'indexAction', new Request(), new Response(), new FilesystemHistory(new HistoryOptions()), @@ -240,12 +237,11 @@ private function assertJsonResponse(ResponseInterface $response, int $status, ar $this->assertSame($expectedBody, json_decode($response->getContent(), true)); } - private function execute(History $history, string $action = 'index'): Response + private function execute(History $history): Response { $response = new Response(); return $this->executeWithServices( - 'clear' === $action ? 'clearAction' : 'indexAction', new Request(), $response, $history, @@ -254,14 +250,13 @@ private function execute(History $history, string $action = 'index'): Response } private function executeWithServices( - string $action, RequestInterface $request, Response $response, History $history, AccessGate $access ): Response { $controller = new HistoryController($history, $access, $request, $response); - $result = $controller->{$action}(); + $result = $controller->openAction(); $this->assertInstanceOf(Response::class, $result); diff --git a/tests/Unit/DebugBar/ProviderTest.php b/tests/Unit/DebugBar/ProviderTest.php index df8c4e7..33ff7c3 100644 --- a/tests/Unit/DebugBar/ProviderTest.php +++ b/tests/Unit/DebugBar/ProviderTest.php @@ -372,7 +372,7 @@ public function testHistoryControllerReadsTheRequestService(): void $request->method('getServer')->willReturn('GET'); $request->method('getQuery')->willReturn('unknown-id'); - $this->assertSame(404, $this->historyController(['request' => $request])->indexAction()->getStatusCode()); + $this->assertSame(404, $this->historyController(['request' => $request])->openAction()->getStatusCode()); } public function testHistoryControllerWithNoRequestServiceUsesANewRequest(): void @@ -380,7 +380,7 @@ public function testHistoryControllerWithNoRequestServiceUsesANewRequest(): void $_ENV[self::ENV_VAR] = 'dev'; $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertSame(200, $this->historyController([])->indexAction()->getStatusCode()); + $this->assertSame(200, $this->historyController([])->openAction()->getStatusCode()); } public function testHistoryDoesNotResolveResponseServicesAtBoot(): void diff --git a/tests/Unit/DebugBar/VersionTest.php b/tests/Unit/DebugBar/VersionTest.php deleted file mode 100644 index 856ae8d..0000000 --- a/tests/Unit/DebugBar/VersionTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE.txt - * file that was distributed with this source code. - */ - -declare(strict_types=1); - -namespace Phalcon\Tests\Unit\DebugBar; - -use Phalcon\DebugBar\Version; -use PHPUnit\Framework\TestCase; - -final class VersionTest extends TestCase -{ - public function testGetReturnsASemverString(): void - { - $version = new Version(); - - $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+/', $version->get()); - } -}