Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Initital dusk test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
emptynick committed Apr 2, 2019
1 parent 4c04d13 commit d77ba64
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@
"Bread\\BreadServiceProvider"
]
}
},
"require-dev": {
"orchestra/testbench-dusk": "3.8"
}
}
32 changes: 32 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?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">

<testsuites>
<testsuite name="Browser">
<directory suffix="Test.php">./tests/Browser</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>

<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
<env name="DB_CONNECTION" value="sqlite"/>
</php>
</phpunit>
53 changes: 53 additions & 0 deletions tests/Browser/RouteTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace Bread\Tests\Browser;

use Laravel\Dusk\Browser;
use Orchestra\Testbench\Dusk\TestCase;

class RouteTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
$app['router']->get('hello', ['as' => 'hi', 'uses' => function () {
return 'hello world';
}]);
$app['router']->get('config', ['as' => 'hi', 'uses' => function () {
return config('new_config_item');
}]);
}

/** @test */
public function can_use_dusk()
{
$this->browse(function (Browser $browser) {
$browser->visit('hello')
->assertSee('hello world');
});
}

/** @test */
public function can_use_multiple_browsers()
{
$this->browse(function (Browser $browser, Browser $browserTwo) {
$browser->visit('hello')
->assertSee('hello world');
$browserTwo->visit('hello')
->assertSee('hello world');
});
}

/** @test */
public function can_tweak_the_application_within_a_test()
{
$this->tweakApplication(function ($app) {
$app['config']->set('new_config_item', 'Fantastic!');
});
$this->assertEquals('Fantastic!', config('new_config_item'));
$this->browse(function (Browser $browser, Browser $browserTwo) {
$browser->visit('config')
->assertSee('Fantastic!');
});
$this->removeApplicationTweaks();
}
}
5 changes: 5 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

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

Orchestra\Testbench\Dusk\Options::withoutUI();

0 comments on commit d77ba64

Please sign in to comment.