GithubHelp home page GithubHelp logo

laravel / browser-kit-testing Goto Github PK

View Code? Open in Web Editor NEW
506.0 506.0 74.0 394 KB

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.

License: MIT License

PHP 100.00%
laravel testing

browser-kit-testing's Introduction

Laravel Logo

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [email protected]. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.

browser-kit-testing's People

Contributors

acacha avatar bytestream avatar crynobone avatar cyrilmazur avatar driesvints avatar ericktucto avatar grahamcampbell avatar jaybizzle avatar jexperton avatar joecohens avatar joelclermont avatar jrhenderson1988 avatar kamui545 avatar lukzgois avatar mauri870 avatar nunomaduro avatar okdewit avatar peter279k avatar psaunders avatar pulasthibandara avatar pulkitjalan avatar rkallenkoot avatar roberto-aguilar avatar scrubmx avatar sinclairt avatar stylecibot avatar svpernova09 avatar taylorotwell avatar themsaid avatar vinkla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

browser-kit-testing's Issues

Need new tag with RefreshDatabase trait support

Thank you for making this package available for laravel 5.4 and 5.5, i'm using this package a lot.

The latest tagged version is 2.0.1 that updated about 3 months ago. The RefreshDatabase Trait has not been supported in that version. I see the master branch has. Could you please add new a tag for latest version that has RefreshDatabase trait support?

Thanks in advance.

External URL testing purpose

i've working with multiple app that built from some stack, there are laravel, codeigniter and native php. The apps actually support single mobile apps as a core system. late enhancement make me confusing about the bug show everywhere when one feature added. i just tried at laravel unit testing before, it can not use external url as url in json() method. i just want to ask , is this repository can help testing multiple url, such as api response only?

Losing access to extended testing tools

When using

use Laravel\BrowserKitTesting\TestCase as BaseTestCase;

over

use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

we lose the ability to use things like "assertDatabaseHas":

Error: Call to undefined method Tests\Unit\UserTest::assertDatabaseHas()

[5.5] Illuminate/Session/Middleware/AuthenticateSession.php breaks actingAs

Laravel: 5.5.40
PHP: 7.1.9
MySQL: 5.7.19

If using the Laravel Middleware "AuthenticateSession", this will cause problems with phpunit tests where using actingAs more than once. For example:

$this->actingAs($adminUser);
$this->visit('adminPage');
$this->actingAs($regularUser);
$this->visit('regularPage');

The problem is that in the session AuthenticateSession Middleware will store a session variable called "password_hash". The first actingAs statement works perfectly, and when visiting any pages the session adds a password_hash field. Once you switch users by using the actingAs statement again, the session maintains all of the same data. Then when you visit the regular page, the AuthenticateSession Middleware notices that the 'password_hash' value actually does not match the hashed password for the regular user, and forces the user to logout at that point. This is not desired behavior because you are no longer acting as that user anymore.

One possible solution would be to update actingAs method to forget the password_hash so that when the AuthenticateSession middleware kicks in later when visiting a page, it won't force a logout and instead will simply add the password_hash field to the session like normal. Something like:

session()->forget('password_hash');

It might make more sense to actually flush the session, since its a completely different user.

Checkbox testing

I have a couple of forms where there are checkboxes that are required.

The input fields get the following attribute name="permissions[]"
But I can't seem to check these checkboxes through testing, I keep getting the following error:

InvalidArgumentException: Cannot set value on a compound field "permissions".

Do I need to specify a index in the name attribute?

Use illuminate/testing

In particular Illuminate\Testing\TestResponse.

Based on my review it would be possible to use TestResponse with browser-kit-testing but the are some differences that we need to manage:

  • assertResponseOk is same as TestResponse::assertOk()
  • assertResponseStatus is same as TestResponse::assertStatus()
  • assertRedirectedTo is similar to TestResponse::assertRedirect()
  • dump() return void but TestResponse::dump() return $this.

There no equivalent to:

  • assertRedirectedToRoute
  • assertRedirectedToAction

Multiple Forms with same name tag

Hello there :)

I am trying to test a page with multiple forms. All the forms use the same field names (editing multiple users at once). My understanding is, that the methods for form testing require the field name. But in my case these are not unique. Is there a way to use the field id instead?

Thanks!

Tag new release

Release 4.0.1 was tagged on March 14, there are 10 commits since then, could we tag 4.0.2 now?

Use of assertIsArray in seeJsonStructure requires phpunit >= 7.5

  • Browser Kit Testing Version: 4.2.0
  • Laravel Version: 5.7
  • PHP Version: 7.2
  • Phpunit version 7.0.3

Description:

I haven't taken the time to dive too far into this but hope this can help others with my issue.

The issue is with compatibility with phpunit 7.*

The phpunit assertion assertIsArray is not added until phpunit 7.5

Steps To Reproduce:

Use assertion seeJsonStructure with wildcard *with library versions as above.

Solution:

  • User can: Downgrade browser-kit-testing to <=4.1 or upgrade phpunit to >=7.5
  • browser-kit-testing >4.1 can: require phpunit >=7.5

Cache

My site pulls keys from a cache to display in Blade views.

Is there a way to use actual cache in the tests (as in, add something to the cache and expect it to be there when visiting the page)?

Upgrade project to Laravel 5.6

composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - laravel/browser-kit-testing v3.0.0 requires phpunit/phpunit ~6.0 -> satisfiable by phpunit/phpunit[6.0.0, 6.0.1, 6.0.10, 6.0.11, 6.0.12, 6.0.13, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.0.9, 6.0.x-dev, 6.1.0, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.x-dev, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.2.4, 6.2.x-dev, 6.3.0, 6.3.1, 6.3.x-dev, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.x-dev, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.x-dev] but these conflict with your requirements or minimum-stability.
    - laravel/browser-kit-testing v3.0.0 requires phpunit/phpunit ~6.0 -> satisfiable by phpunit/phpunit[6.0.0, 6.0.1, 6.0.10, 6.0.11, 6.0.12, 6.0.13, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.0.9, 6.0.x-dev, 6.1.0, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.x-dev, 6.2.0, 6.2.1, 6.2.2, 6.2.3, 6.2.4, 6.2.x-dev, 6.3.0, 6.3.1, 6.3.x-dev, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.x-dev, 6.5.0, 6.5.1, 6.5.2, 6.5.3, 6.5.4, 6.5.5, 6.5.6, 6.5.x-dev] but these conflict with your requirements or minimum-stability.
    - Installation request for laravel/browser-kit-testing ^3.0 -> satisfiable by laravel/browser-kit-testing[v3.0.0].

Since L5.6 requires PHPUnit 7.0

Missing dependency

Am I correct in saying this depends on symfony/dom-crawler? Specifically in the InteractsWithPages trait.

[SOLVED] Call to a member function selectLink() on null

  • Browser Kit Testing Version: 5.1.3
  • Laravel Version: 6.14.0
  • PHP Version: 7.4.0
  • Database Driver & Version: N/A

Description:

Getting an error from InteractsWithPages saying Call to a member function selectLink() on null when trying to run a browser kit test. Looks like crawler is null on the class at that point.

vagrant@homestead:~/projects/foobar$ phpunit --filter ContinueTest 
PHPUnit 8.5.2 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 216 ms, Memory: 20.00 MB

There was 1 error:

1) Tests\Feature\Play\StartToMapTest::testStartToMap
Error: Call to a member function selectLink() on null

/home/vagrant/projects/foobar/vendor/laravel/browser-kit-testing/src/Concerns/InteractsWithPages.php:497
/home/vagrant/projects/foobar/tests/Feature/Play/ContinueTest.php:13

ERRORS!
Tests: 1, Assertions: 2, Errors: 1.

Steps To Reproduce:

  • On a fresh install of Laravel 6.14.0
  • Ran composer require laravel/browser-kit-testing --dev as in the documentation.

Test looks like this:

<?php

namespace Tests\Feature;

use Tests\TestCase;

class ContinueTest extends TestCase
{
    public function testContinue()
    {
        $this->get('/')->assertResponseOk()->see('Continue');

        $this->click('Continue');
    }
}

The parent Tests\TestCase class looks like this:

<?php

namespace Tests;

use Laravel\BrowserKitTesting\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication;

    public $baseUrl = 'http://localhost';
}

Not compatible with PHPUnit 6

The package uses PHPUnit classes but does not list it as a dependency. That means you can install it alongside PHPUnit 6 while in reality it will crash. I think "phpunit/phpunit": "<=6.0" (or something) should be added as dependency of this package

ADD Null Safety

add Null safety to whereever appropriate, so things like this wouldn't be fatal:

ErrorException

  Trying to access array fset on value of type null

  at vendor/laravel/browser-kit-testing/src/Concerns/ImpersonatesUsers.php:32
     28▕      * @return void
     29▕      */
     30▕     public function be(UserContract $user, $driver = null)
     31▕     {
  ➜  32▕         $this->app['auth']->guard($driver)->setUser($user);
     33▕     }
     34▕ }
     35▕ 

Outdated MocksApplicationServices.php implementation

Comparison of:

withoutEvents() diff:

$mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');

$mock->shouldReceive('fire', 'dispatch', 'getCommandHandler')->andReturnUsing(function ($called) {
    $this->firedEvents[] = $called;
});

$this->app->instance('events', $mock);

return $this;
$mock = Mockery::mock(EventsDispatcherContract::class)->shouldIgnoreMissing();

$mock->shouldReceive('dispatch', 'until')->andReturnUsing(function ($called) {
    $this->firedEvents[] = $called;
});

Event::clearResolvedInstances();

$this->app->instance('events', $mock);

return $this;

I noticed this having tried to use expectsEvents() and ran into a mockery error stating until was called but had not been mocked.

There are other differences https://www.diffchecker.com/HRM1BixO

Sail and parallel testing

Browser Kit Testing Version

7.1

Laravel Version

10.10

PHP Version

8.3

Database Driver & Version

MySQL 8

Description

I noticed that BrowserKit does not read the correct database with ParaTest. Replicated on a fresh Laravel Sail install today, see below to reproduce or run tests here: https://github.com/knobel-dk/browser-kit-paratest-bug.

Steps To Reproduce

With Sail:

Clone https://github.com/knobel-dk/browser-kit-paratest-bug and run tests will give:

ParaTest v7.3.1 upon PHPUnit 10.5.9 by Sebastian Bergmann and contributors.

Processes:     8
Runtime:       PHP 8.3.2-1+ubuntu22.04.1+deb.sury.org+1
Configuration: /var/www/html/phpunit.xml

F.                                                                  2 / 2 (100%)

Time: 00:00.848, Memory: 12.00 MB

There was 1 failure:

1) Tests\Feature\ExampleTest::test_the_application_returns_a_successful_response
Failed asserting that 'testing' [ASCII](length: 7) contains "testing_test_" [ASCII](length: 13).

/var/www/html/tests/Feature/ExampleTest.php:19

FAILURES!
Tests: 2, Assertions: 2, Failures: 1.

Starting from scratch

curl -s "https://laravel.build/example-app" | bash
cd example-app && ./vendor/bin/sail up
sh vendor/bin/sail composer require laravel/sanctum laravel/browser-kit-testing brianium/paratest

Copy these three files into the repo:

  1. https://github.com/knobel-dk/browser-kit-paratest-bug/blob/main/tests/TestCase.php
  2. https://github.com/knobel-dk/browser-kit-paratest-bug/blob/main/tests/Unit/ExampleTest.php
  3. https://github.com/knobel-dk/browser-kit-paratest-bug/blob/main/tests/Feature/ExampleTest.php

Run this to get the output above:

sh vendor/bin/sail php artisan test -p

Dependency Issue on Laravel 6.9.x

  • Browser Kit Testing Version: v5.1.3
  • Laravel Version: v6.9.0
  • PHP Version: 7.2.22
  • Database Driver & Version: mysql Ver 15.1 Distrib 10.2.27-MariaDB.

Description:

Hi, when installing this package to Laravel 6.9.x, I have got this dependency error.

  Problem 1
    - Conclusion: don't install laravel/browser-kit-testing v5.1.3
    - Installation request for symfony/css-selector (locked at v5.0.2) -> satisfiable by symfony/css-selector[v5.0.2].
    - Conclusion: remove laravel/framework v6.9.0
    - Conclusion: don't install laravel/framework v6.9.0
    - laravel/browser-kit-testing v5.1.0 requires illuminate/http ~5.7.0|~5.8.0 -> satisfiable by illuminate/http[5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
...
...
    - don't install illuminate/http 5.7.17|don't install laravel/framework v6.9.0
    - don't install illuminate/http 5.7.18|don't install laravel/framework v6.9.0
...
...
    - don't install illuminate/http v5.8.8|don't install laravel/framework v6.9.0
    - don't install illuminate/http v5.8.9|don't install laravel/framework v6.9.0
    - Installation request for laravel/framework (locked at v6.9.0, required as ^6.2) -> satisfiable by laravel/framework[v6.9.0].
    - Installation request for laravel/browser-kit-testing ^5.1 -> satisfiable by laravel/browser-kit-testing[v5.1.0, v5.1.1, v5.1.2, v5.1.3].

Installation failed, reverting ./composer.json to its original content.

Steps To Reproduce:

$ laravel new laravel_6x
$ cd laravel_6x
$ composer require laravel/browser-kit-testing --dev

I think the problem is this dependency.
https://github.com/laravel/browser-kit-testing/blob/5.0/composer.json#L23
Somehow we were forced to use symfony/css-selector version 5.x.

Maybe we should use change these lines https://github.com/laravel/browser-kit-testing/blob/5.0/composer.json#L22-L26 to :

"symfony/console": "^4.2 | ^5.0",
"symfony/css-selector": "^4.2 | ^5.0",
"symfony/dom-crawler": "^4.2 | ^5.0",
"symfony/http-foundation": "^4.2 | ^5.0",
"symfony/http-kernel": "^4.2 | ^5.0"

Thanks.

Support for parallel testing

  • Browser Kit Testing Version: 6.2.2
  • Laravel Version: 8.51.0
  • PHP Version: 8
  • Database Driver & Version: MySQL 5.7

Description:

It doesn't look like browser-kit-testing has support for the new parallel testing functionality.

Is it something that would be considered to be added to the library, or should it only be used to support apps that have these legacy tests?

I'd be open to attempting a PR for this.

Steps To Reproduce:

  • Write a test that extends Laravel\BrowserKitTesting\TestCase.
  • Run tests using php artisan test --parallel.

Custom headers

Please forgive me if I'm overlooking a way to do this but I'm having trouble figuring out how set headers on visit/get/post etc...

My specific use case is that I'd like to send user agents to verify that android and ios specific parts of my pages are working properly.

It looks like in the Illuminate version of MakesHttpRequests that functionality is available via MakesHttpRequests::withHeader, is that something y'all might consider backporting to browser-kit-testing?

https://github.com/laravel/framework/blob/5.6/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php#L55-L59

Thanks!

Infinite redirect loop when testing a controller utilizing back() method on 5.8

See comment on laravel/framework#27731 (comment).

Given some controller route with a return redirect()->back():

<?php
public function archive($model)
{
    $model->archive();
    return redirect()->back();
}

And a browserkit test:

<?php
$this->actingAs($user)
    ->visit('model.show')
    ->click('archive')
    ->see(...)

This is a simple "show" route + view, with an "archive" button + GET route which is this case is set up to just do a redirect()->back() again to the "show" page (I know it's not super REST-compliant, it's a legacy system).

After migrating to Laravel 5.8, I noticed that some tests would rapidly fill up storage/framework/session directory with session files (hundreds of gigabytes).

It seems something changed regarding the way the session stores the previous URL.

Both with Laravel 5.7.21 and 5.8.3 everything works correctly when used with an actual browser, the "previous URL" on the archive action is identical to the "show" route.

When using the ->visit(...)->click(...) methods in browserkit tests, the previous URL during the click request is the "archive" route itself, which leads to an infinite redirect loop.

Outdated MocksApplicationServices.php implementation

  • Browser Kit Testing Version: 5.1.4
  • Laravel Version: 6.18.38
  • PHP Version: n/a - 7.3.21
  • Database Driver & Version: n/a

Description:

Comparison of:

withoutEvents() diff:

$mock = Mockery::mock('Illuminate\Contracts\Events\Dispatcher');

$mock->shouldReceive('fire', 'dispatch', 'getCommandHandler')->andReturnUsing(function ($called) {
    $this->firedEvents[] = $called;
});

$this->app->instance('events', $mock);

return $this;
$mock = Mockery::mock(EventsDispatcherContract::class)->shouldIgnoreMissing();

$mock->shouldReceive('dispatch', 'until')->andReturnUsing(function ($called) {
    $this->firedEvents[] = $called;
});

Event::clearResolvedInstances();

$this->app->instance('events', $mock);

return $this;

I noticed this having tried to use expectsEvents() and ran into a mockery error stating until was called but had not been mocked.

There are other differences https://www.diffchecker.com/HRM1BixO

Steps To Reproduce:

$this->expectsEvents([Foo::class]);

Assert response is json broken in v6

  • Browser Kit Testing Version: 6.22
  • Laravel Version: 7.30.5
  • PHP Version: 7.4.26
  • Database Driver & Version:

Description:

In v6 seeJson() is no longer possible and produces:

TypeError : Argument 1 passed to Laravel\BrowserKitTesting\TestCase::seeJsonEquals() must be of the type array, null given

Broken by d472e1c which proclaimed:

This mainly aim to check if response is actually JSON.

This is what the reproducer below also intends to do.

Steps To Reproduce:

$this->json('GET', route('???'))
            ->seeJson()
            ->assertResponseOk();

Screenshot

Is there any chance to make a screenshot of a div with this package?

Does browser-kit run with the latest Spark install?

  • Browser Kit Testing Version: latest
  • Laravel Version: 6.12.0
  • PHP Version: 7.4.1
  • Database Driver & Version:

Description:

Hi there!

First of all: thanks for keeping BrowserKit alive! I was afraid it had disappeared forever :-)

I'm trying to install browser-kit-testing on a recently created Spark project.

When I do, I get this:

composer require laravel/browser-kit-testing --dev
    1/8:	http://repo.packagist.org/p/provider-2020-01$c39e1186f449574a0790769e93aab9920d68cfb7be479be08cfc58f88b11cfe7.json
    2/8:	http://repo.packagist.org/p/provider-latest$a0e999fca5c76fb5fa79ddf83246567a59678edc74589d1a270a7fa4fd246562.json
    3/8:	http://repo.packagist.org/p/provider-2015$0aac724e76be925bf6cdb05df0ca07f750af44bf56a636fc7e0efacee6735612.json
    4/8:	http://repo.packagist.org/p/provider-2019-07$0196823b45ccce5c4f9cbd9ca18a5abb308973a21ee163e14b6ddefb5c5e2c98.json
    5/8:	http://repo.packagist.org/p/provider-2016$4fe5dd496dcc96679e3cf7a59f10d7478472177a1dcdb95b7005666a27dd1702.json
    6/8:	http://repo.packagist.org/p/provider-2019-10$cd605eec905271ae38176d1bca62603519262e6c9bf2772f599a1c7550c07c97.json
    7/8:	http://repo.packagist.org/p/provider-2017$0a2bf2c6a5b0193af948b3920a7c328dc182780018402a451a897370d15b05dd.json
    8/8:	http://repo.packagist.org/p/provider-2018$20de72af93220ca235e9a0d724e38f4e9dcd6665b78f7b5b5796f7ce777a5335.json
    Finished: success: 8, skipped: 0, failure: 0, total: 8
Using version ^5.1 for laravel/browser-kit-testing
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/browser-kit-testing v5.1.3
    - Installation request for symfony/css-selector (locked at v5.0.3) -> satisfiable by symfony/css-selector[v5.0.3].
    - Conclusion: remove laravel/framework v6.12.0
    - Conclusion: don't install laravel/framework v6.12.0
    - laravel/browser-kit-testing v5.1.0 requires illuminate/http ~5.7.0|~5.8.0 -> satisfiable by illuminate/http[5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
    - laravel/browser-kit-testing v5.1.1 requires illuminate/http ~5.7.0|~5.8.0 -> satisfiable by illuminate/http[5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
    - laravel/browser-kit-testing v5.1.2 requires illuminate/http ~5.7.0|~5.8.0 -> satisfiable by illuminate/http[5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9].
    - don't install illuminate/http 5.8.x-dev|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.0|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.11|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.12|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.14|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.15|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.17|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.18|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.19|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.2|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.20|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.22|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.24|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.27|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.28|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.29|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.3|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.30|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.31|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.32|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.33|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.34|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.35|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.36|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.4|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.8|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.8.9|don't install laravel/framework v6.12.0
    - don't install illuminate/http 5.7.17|don't install laravel/framework v6.12.0
    - don't install illuminate/http 5.7.18|don't install laravel/framework v6.12.0
    - don't install illuminate/http 5.7.19|don't install laravel/framework v6.12.0
    - don't install illuminate/http 5.7.x-dev|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.0|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.1|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.10|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.11|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.15|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.2|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.20|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.21|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.22|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.23|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.26|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.27|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.28|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.3|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.4|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.5|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.6|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.7|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.8|don't install laravel/framework v6.12.0
    - don't install illuminate/http v5.7.9|don't install laravel/framework v6.12.0
    - Installation request for laravel/framework (locked at v6.12.0, required as ^6.2) -> satisfiable by laravel/framework[v6.12.0].
    - Installation request for laravel/browser-kit-testing ^5.1 -> satisfiable by laravel/browser-kit-testing[v5.1.0, v5.1.1, v5.1.2, v5.1.3].


Installation failed, reverting ./composer.json to its original content.

I'm not sure if I'm doing anything wrong, or if this just means that it's no longer supported?
Any help is appreciated :)

Steps To Reproduce:

  • Install latest Spark
  • Run composer require laravel/browser-kit-testing --dev

Update dependencies to composer.json

There are several dependencies that are not included.

For example:

Dependence illuminate/foundation ?
TestCase.php#L8, TestCase.php#L10-L4, TestCase.php#L31
illuminate/foundation is abandoned !!!

Event & Job Testing is not backwards compatible (Laravel 5.3 --> 5.4)

Noticed an issue when running our legacy tests that when logic fires both events and dispatches queue jobs: the event listeners will not fire if there are calls for expecting queue jobs.

Example:

  1. event should fire with non-queued listener to update additional fields
  2. more logic happens, eventually the desired state is achieved
  3. an queue job is dispatched to do something with this state (email, sms, push...)

Test:

  1. we need to let the events & listeners propagate to ensure the correct state is achieved and just want to assert that the (email, sms, push, ...) job is dispatched so we use the $this->expectsJobs(...)
  2. when running the tests, the event fire happens but the listeners do not run

Since there are changes with how events are "fired" using the "dispatch" method in the migration from Laravel 5.3 to 5.4, this may not be fixable but i thought i would bring it up since the laravel documentation states that the BrowserKitTestCase is fully backwards compatible

无法调用ChoiceFormField类的disableValidation方法

请问一个问题,我在使用laravel/browser-kit-testing包做浏览器管理端测试的时候,使用的是laravel-admin搭建的临时后台。

我在测试select单选框的时候使用的是ajax异步加载的方式,而options备选框的返回为空(为了节省内存),此时我传对应表单进行测试验证的时候,出现了“您所提交的值不在备选框内“”的错误提示,因此我需要关闭表单验证。
由于创建ChoiceFormField类的对象需要找到当前表单的DOMElement对象,才能够得到当前页面的测试对象。我想问一下我怎么拿到当前页面的DOMElement然后执行disableValidation方法关闭表单验证,非常感谢!

Phpunit failing

  • Browser Kit Testing Version:5.1.2
  • Laravel/Lumen Version: 5.8
  • PHP Version: 7.3.2
  • PHPUnit Version: Either 7.5.13 or 8.x

Description:

Failing to run tests getting the following error.
Error: Call to undefined method App\Console\Kernel::bootstrap()

Based on this and README of this repo. I created a trait CreatesApplication.php and call it from the BrowserKitTestCase.php.
Same results having even if instead of having trait I have a createApplication function on BrowserKitTestCase.php.

Steps To Reproduce:

Run phpunit

Add documentation about Laravel versions compatibility

Hi, I have Laravel 6 and was not able to install laravel/browser-kit-testing according to current docs, it appeared that I had to install specific version ^5 plus there are issues with other dependencies like "symfony/css-selector", this should be in docs.

Testing environment is not detected

Hello!

I'm trying to run database migrations inside a Feature test class. My code is of Laravel 5.3 and I did update it to use BrowserKit so it looks like that :

<?php

namespace Tests\Feature;

use Tests\BrowserKitTest as TestCase;

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;

use App\User;

class LoginAPITest extends TestCase
{
	use DatabaseMigrations;
}

When I run my tests, the env.testing file seem not to be detected, as the migrations are performed on my .env database instead of the one defined in env.testing

I hope the information I provided will help! Feel free to tell me if I just did something the wrong way...

Thanks by advance!

Warnings about withoutMiddleware() in Laravel 5.5

The change of method signature in laravel/framework@3879cb6 makes the MakesHttpRequests in this package incompatible with the one that comes with laravel/framework.

PHP Warning: Declaration of Laravel\BrowserKitTesting\Concerns\MakesHttpRequests::withoutMiddleware() should be compatible with Illuminate\Foundation\Testing\TestCase::withoutMiddleware($middleware = NULL)

exception when executing phpunit

  • Browser Kit Testing Version: v2.0.1
  • Laravel Version: v5.8.11
  • PHP Version: 7.2.12
  • PHPUnit Version: 6.5.14
  • Database Driver & Version: sqlite

Description:

PHPUnit 7.1.4 by Sebastian Bergmann and contributors.

PHP Fatal error:  Declaration of Laravel\BrowserKitTesting\Constraints\PageConstraint::fail($crawler, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) must be compatible with PHPUnit\Framework\Constraint\Constraint::fail($other, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL): void in /Project/nginx/laravel-admin-select2/vendor/laravel/browser-kit-testing/src/Constraints/PageConstraint.php on line 124

In PageConstraint.php line 124:
                                                                                                                                                    
  Declaration of Laravel\BrowserKitTesting\Constraints\PageConstraint::fail($crawler, $description, ?SebastianBergmann\Comparator\ComparisonFailur  
  e $comparisonFailure = NULL) must be compatible with PHPUnit\Framework\Constraint\Constraint::fail($other, $description, ?SebastianBergmann\Comp  
  arator\ComparisonFailure $comparisonFailure = NULL): void                                                                                         
                                                                                                                                                    


Fatal error: Declaration of Laravel\BrowserKitTesting\Constraints\PageConstraint::fail($crawler, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL) must be compatible with PHPUnit\Framework\Constraint\Constraint::fail($other, $description, ?SebastianBergmann\Comparator\ComparisonFailure $comparisonFailure = NULL): void in /Project/nginx/laravel-admin-select2/vendor/laravel/browser-kit-testing/src/Constraints/PageConstraint.php on line 124

Extra infomation:

I can see
vendor/laravel/browser-kit-testing/src/Constraints/PageConstraint.php's fail method declaring

    /**
     * Throw an exception for the given comparison and test description.
     *
     * @param  \Symfony\Component\DomCrawler\Crawler|string  $crawler
     * @param  string  $description
     * @param  \SebastianBergmann\Comparator\ComparisonFailure|null  $comparisonFailure
     * @return void
     *
     * @throws \PHPUnit\Framework\ExpectationFailedException
     */
    protected function fail($crawler, $description, ComparisonFailure $comparisonFailure = null)
    {

and
vendor/phpunit/phpunit/src/Framework/Constraint/Constraint.php's declaring

    /**
     * Throws an exception for the given compared value and test description
     *
     * @param mixed             $other             Evaluated value or object.
     * @param string            $description       Additional information about the test
     * @param ComparisonFailure $comparisonFailure
     *
     * @throws ExpectationFailedException
     */
    protected function fail($other, $description, ComparisonFailure $comparisonFailure = null)
    {

They have different parameter declares. Please check the compatible with phpunit which version i pasted.

Database migrations aren't run when using the trait

Using the dev version of Laravel (namely the yet-to-be-released 5.4) I've done as the docs state, but the migrations are not being run.

I'm following along Adam Wathan's TDD course so using the previous ->visit and ->see methods.

Latest release is not up to date

Hey !

I still use Browser-kit a lot before moving to Dusk. Since my upgrade on Laravel 5.5, I use the RefreshDatabase Trait instead of the old DatabaseMigrations.

It has been fixed (v2.0.1...master) in this package but it's not available as composer dependency yet.

Could you update it to use it now ?

Thanks !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.