68 - Removing the Browser Kit Dependency

This commit is contained in:
Adam Wathan
2017-02-02 16:48:42 -05:00
parent 4f91fbef08
commit 09e1d5a11d
5 changed files with 90 additions and 161 deletions

View File

@@ -9,8 +9,7 @@
"laravel/framework": "5.4.*",
"zondicons/blade-bridge": "^0.1.0",
"stripe/stripe-php": "^4.3",
"guzzlehttp/guzzle": "^6.2",
"laravel/browser-kit-testing": "^1.0"
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"fzaninotto/faker": "~1.4",

163
composer.lock generated
View File

@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "1a295f4015af6d87c280a4b5724dffdf",
"content-hash": "dc21df0223e675f996fc46355c30b69c",
"hash": "828692e34e61c07c42dabf44fb20ac21",
"content-hash": "e657ab8d9ccb9253049b2ef80ba123f6",
"packages": [
{
"name": "doctrine/inflector",
@@ -287,53 +287,6 @@
],
"time": "2016-06-24 23:00:38"
},
{
"name": "laravel/browser-kit-testing",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/laravel/browser-kit-testing.git",
"reference": "60e038e3dcfef2977347f9610c14b48721802278"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/browser-kit-testing/zipball/60e038e3dcfef2977347f9610c14b48721802278",
"reference": "60e038e3dcfef2977347f9610c14b48721802278",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Laravel\\BrowserKitTesting\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
}
],
"description": "Provides backwards compatibility for BrowserKit testing in Laravel 5.4.",
"keywords": [
"laravel",
"testing"
],
"time": "2017-01-25 13:07:25"
},
{
"name": "laravel/framework",
"version": "v5.4.8",
@@ -1273,62 +1226,6 @@
"homepage": "https://symfony.com",
"time": "2017-01-02 20:32:22"
},
{
"name": "symfony/dom-crawler",
"version": "v3.1.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/7eede2a901a19928494194f7d1815a77b9a473a0",
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"symfony/css-selector": "~2.8|~3.0"
},
"suggest": {
"symfony/css-selector": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\DomCrawler\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-01-21 17:13:55"
},
{
"name": "symfony/event-dispatcher",
"version": "v3.2.2",
@@ -3383,6 +3280,62 @@
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03 07:35:21"
},
{
"name": "symfony/dom-crawler",
"version": "v3.1.10",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/7eede2a901a19928494194f7d1815a77b9a473a0",
"reference": "7eede2a901a19928494194f7d1815a77b9a473a0",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"symfony/css-selector": "~2.8|~3.0"
},
"suggest": {
"symfony/css-selector": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\DomCrawler\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2017-01-21 17:13:55"
},
{
"name": "symfony/yaml",
"version": "v3.2.2",

View File

@@ -1,39 +0,0 @@
<?php
use App\Exceptions\Handler;
use Illuminate\Contracts\Debug\ExceptionHandler;
abstract class BrowserKitTestCase extends Laravel\BrowserKitTesting\TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected $baseUrl = 'http://localhost';
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
return $app;
}
protected function disableExceptionHandling()
{
$this->app->instance(ExceptionHandler::class, new class extends Handler {
public function __construct() {}
public function report(Exception $e) {}
public function render($request, Exception $e) {
throw $e;
}
});
}
}

View File

@@ -7,7 +7,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class PurchaseTicketsTest extends BrowserKitTestCase
class PurchaseTicketsTest extends TestCase
{
use DatabaseMigrations;
@@ -21,10 +21,25 @@ class PurchaseTicketsTest extends BrowserKitTestCase
private function orderTickets($concert, $params)
{
$savedRequest = $this->app['request'];
$this->json('POST', "/concerts/{$concert->id}/orders", $params);
$this->response = $this->json('POST', "/concerts/{$concert->id}/orders", $params);
$this->app['request'] = $savedRequest;
}
private function assertResponseStatus($status)
{
$this->response->assertStatus($status);
}
private function seeJsonSubset($data)
{
$this->response->assertJson($data);
}
private function decodeResponseJson()
{
return $this->response->decodeResponseJson();
}
private function assertValidationError($field)
{
$this->assertResponseStatus(422);

View File

@@ -6,7 +6,7 @@ use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ViewConcertListingTest extends BrowserKitTestCase
class ViewConcertListingTest extends TestCase
{
use DatabaseMigrations;
@@ -26,17 +26,18 @@ class ViewConcertListingTest extends BrowserKitTestCase
'additional_information' => 'For tickets, call (555) 555-5555.',
]);
$this->visit('/concerts/'.$concert->id);
$response = $this->get('/concerts/'.$concert->id);
$this->see('The Red Chord');
$this->see('with Animosity and Lethargy');
$this->see('December 13, 2016');
$this->see('8:00pm');
$this->see('32.50');
$this->see('The Mosh Pit');
$this->see('123 Example Lane');
$this->see('Laraville, ON 17916');
$this->see('For tickets, call (555) 555-5555.');
$response->assertStatus(200);
$response->assertSee('The Red Chord');
$response->assertSee('with Animosity and Lethargy');
$response->assertSee('December 13, 2016');
$response->assertSee('8:00pm');
$response->assertSee('32.50');
$response->assertSee('The Mosh Pit');
$response->assertSee('123 Example Lane');
$response->assertSee('Laraville, ON 17916');
$response->assertSee('For tickets, call (555) 555-5555.');
}
/** @test */
@@ -44,8 +45,8 @@ class ViewConcertListingTest extends BrowserKitTestCase
{
$concert = factory(Concert::class)->states('unpublished')->create();
$this->get('/concerts/'.$concert->id);
$response = $this->get('/concerts/'.$concert->id);
$this->assertResponseStatus(404);
$response->assertStatus(404);
}
}