Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add browser test #639

Merged
merged 6 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
/demo/bridge/*/vendor
/src/DebugBar/Resources/vendor
.phpunit.result.cache
/drivers
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion demo/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

include __DIR__ . '/../tests/bootstrap.php';
include __DIR__ . '/../vendor/autoload.php';

// for stack data
session_start();
Expand Down
39 changes: 17 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -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>
42 changes: 42 additions & 0 deletions tests/DebugBar/Browser/BasicBrowserTest.php
Original file line number Diff line number Diff line change
@@ -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');

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function setUp(): void

$stub = $this->getMockBuilder('DebugBar\Bridge\Propel2Collector')
->disableOriginalConstructor()
->setMethods(array('getDataFormatter', 'getHandler', 'getConfig'))
->onlyMethods(array('getDataFormatter', 'getHandler', 'getConfig'))
->getMock();

$this->dataFormatter = new DataFormatter();
Expand Down