1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-16 21:08:34 +01:00

Add browser test (#639)

* Add browser test with Panther
This commit is contained in:
Barry vd. Heuvel 2024-03-30 08:50:08 +01:00 committed by GitHub
parent 6706ad4d2d
commit 2bfe379a66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 84 additions and 28 deletions

View File

@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
php: [8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1]
php: [8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2]
name: PHP${{ matrix.php }}

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ composer.lock
/demo/bridge/*/vendor
/src/DebugBar/Resources/vendor
.phpunit.result.cache
/drivers

View File

@ -105,3 +105,14 @@ $debugbar["messages"]->addMessage("hello world!");
- `ExceptionsCollector` (*exceptions*)
Learn more about DebugBar in the [docs](http://phpdebugbar.com/docs).
## Demo
To run the demo, clone this repository and start the Built-In PHP webserver from the root:
```
php -S localhost:8000
```
Then visit http://localhost:8000/demo

View File

@ -17,19 +17,26 @@
}
],
"require": {
"php": "^7.1|^8",
"php": "^7.2|^8",
"psr/log": "^1|^2|^3",
"symfony/var-dumper": "^4|^5|^6|^7"
},
"require-dev": {
"phpunit/phpunit": ">=7.5.20 <10.0",
"twig/twig": "^1.38|^2.7|^3.0"
"phpunit/phpunit": "^8|^9",
"twig/twig": "^1.38|^2.7|^3.0",
"symfony/panther": "^1|^2.1",
"dbrekelmans/bdi": "^1"
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"autoload-dev": {
"psr-4": {
"DebugBar\\": "tests/DebugBar/"
}
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",

View File

@ -1,6 +1,6 @@
<?php
include __DIR__ . '/../tests/bootstrap.php';
include __DIR__ . '/../vendor/autoload.php';
// for stack data
session_start();

View File

@ -1,24 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="DebugBar Test Suite">
<directory>./tests/DebugBar/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./src/DebugBar/</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="tests/bootstrap.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="DebugBar Test Suite">
<directory>./tests/DebugBar/</directory>
</testsuite>
</testsuites>
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension"/>
</extensions>
<php>
<server name="PANTHER_WEB_SERVER_DIR" value="./"/>
</php>
<source>
<include>
<directory>./src/DebugBar/</directory>
</include>
</source>
</phpunit>

View File

@ -0,0 +1,42 @@
<?php
namespace DebugBar\Tests;
use DebugBar\DebugBar;
use DebugBar\DebugBarException;
use DebugBar\Tests\DataCollector\MockCollector;
use DebugBar\Tests\Storage\MockStorage;
use DebugBar\RandomRequestIdGenerator;
use Facebook\WebDriver\WebDriverElement;
use Symfony\Component\Panther\PantherTestCase;
class BasicBrowserTest extends PantherTestCase
{
public function testDebugbar(): void
{
// Start demo
$client = static::createPantherClient();
$client->request('GET', '/demo');
// Wait for Debugbar to load
$crawler = $client->waitFor('.phpdebugbar-body');
$firstTab = $crawler->filter('a.phpdebugbar-tab')->link();
$client->click($firstTab);
$crawler = $client->waitForVisibility('.phpdebugbar-widgets-messages .phpdebugbar-widgets-list');
$messages = $crawler->filter('.phpdebugbar-widgets-messages .phpdebugbar-widgets-value')
->each(function(WebDriverElement $node){
return $node->getText();
});
$this->assertEquals('hello', $messages[0]);
$this->assertCount(4, $messages);
$firstTab = $crawler->filter('a.phpdebugbar-tab')->link();
$client->click($firstTab);
$client->waitForInvisibility('.phpdebugbar-widgets-messages .phpdebugbar-widgets-list');
}
}

View File

@ -46,7 +46,7 @@ class Propel2CollectorTest extends DebugBarTestCase
$stub = $this->getMockBuilder('DebugBar\Bridge\Propel2Collector')
->disableOriginalConstructor()
->setMethods(array('getDataFormatter', 'getHandler', 'getConfig'))
->onlyMethods(array('getDataFormatter', 'getHandler', 'getConfig'))
->getMock();
$this->dataFormatter = new DataFormatter();