forked from barryvdh/laravel-debugbar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test with Dusk * No UI * composer fix-style * Update BrowserTestCase.php * Update matrix * Update run-tests.yml * Update composer.json * Start with 6.x Co-authored-by: laravel-debugbar <laravel-debugbar@users.noreply.github.com>
- Loading branch information
1 parent
4fe9d74
commit 37dc7a3
Showing
6 changed files
with
144 additions
and
9 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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ composer.phar | |
composer.lock | ||
.DS_Store | ||
.phpunit.result.cache | ||
/tests/Browser |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Barryvdh\Debugbar\Tests; | ||
|
||
use Barryvdh\Debugbar\Facade; | ||
use Barryvdh\Debugbar\ServiceProvider; | ||
|
||
class BrowserTestCase extends \Orchestra\Testbench\Dusk\TestCase | ||
{ | ||
protected static $baseServeHost = '127.0.0.1'; | ||
protected static $baseServePort = 9292; | ||
|
||
/** | ||
* Get package providers. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return array | ||
*/ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ServiceProvider::class]; | ||
} | ||
|
||
/** | ||
* Get package aliases. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return array | ||
*/ | ||
protected function getPackageAliases($app) | ||
{ | ||
return ['Debugbar' => Facade::class]; | ||
} | ||
} |
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,91 @@ | ||
<?php | ||
|
||
namespace Barryvdh\Debugbar\Tests; | ||
|
||
use Illuminate\Routing\Router; | ||
|
||
class DebugbarBrowserTest extends BrowserTestCase | ||
{ | ||
|
||
/** | ||
* Define environment setup. | ||
* | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return void | ||
*/ | ||
protected function getEnvironmentSetUp($app) | ||
{ | ||
$app['env'] = 'local'; | ||
|
||
// $app['config']->set('app.debug', true); | ||
|
||
/** @var Router $router */ | ||
$router = $app['router']; | ||
|
||
$this->addWebRoutes($router); | ||
$this->addApiRoutes($router); | ||
|
||
\Orchestra\Testbench\Dusk\Options::withoutUI(); | ||
} | ||
|
||
/** | ||
* @param Router $router | ||
*/ | ||
protected function addWebRoutes(Router $router) | ||
{ | ||
$router->get('web/plain', [ | ||
'uses' => function () { | ||
return 'PONG'; | ||
} | ||
]); | ||
|
||
$router->get('web/html', [ | ||
'uses' => function () { | ||
return '<html><head></head><body>HTMLPONG</body></html>'; | ||
} | ||
]); | ||
} | ||
|
||
/** | ||
* @param Router $router | ||
*/ | ||
protected function addApiRoutes(Router $router) | ||
{ | ||
$router->get('api/ping', [ | ||
'uses' => function () { | ||
return response()->json(['status' => 'pong']); | ||
} | ||
]); | ||
} | ||
|
||
public function testItInjectsOnPlainText() | ||
{ | ||
$this->browse(function ($browser) { | ||
$browser->visit('web/plain') | ||
->assertSee('PONG') | ||
->waitFor('.phpdebugbar') | ||
->assertSee('GET web/plain'); | ||
}); | ||
} | ||
|
||
public function testItInjectsOnHtml() | ||
{ | ||
$this->browse(function ($browser) { | ||
$browser->visit('web/html') | ||
->assertSee('HTMLPONG') | ||
->waitFor('.phpdebugbar') | ||
->assertSee('GET web/html'); | ||
}); | ||
} | ||
|
||
public function testItDoesntInjectOnJson() | ||
{ | ||
$this->browse(function ($browser) { | ||
$browser->visit('api/ping') | ||
->assertSee('pong') | ||
->assertSourceMissing('debugbar') | ||
->assertDontSee('GET api/ping'); | ||
}); | ||
} | ||
} |
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