laravel / browser-kit-testing Goto Github PK
View Code? Open in Web Editor NEWProvides backwards compatibility for BrowserKit testing in the latest Laravel release.
License: MIT License
Provides backwards compatibility for BrowserKit testing in the latest Laravel release.
License: MIT License
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▕
If the select box's data is populate by a ajax call, unable to get options of the select box
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
.
Run phpunit
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 !!!
I would to simulate multiple simultaneous connections and form submit action on a Laravel instance to evaluate evaluate how many users can the website take. Can this be done with this package ?
请问一个问题,我在使用laravel/browser-kit-testing包做浏览器管理端测试的时候,使用的是laravel-admin搭建的临时后台。
我在测试select单选框的时候使用的是ajax异步加载的方式,而options备选框的返回为空(为了节省内存),此时我传对应表单进行测试验证的时候,出现了“您所提交的值不在备选框内“”的错误提示,因此我需要关闭表单验证。
由于创建ChoiceFormField类的对象需要找到当前表单的DOMElement对象,才能够得到当前页面的测试对象。我想问一下我怎么拿到当前页面的DOMElement然后执行disableValidation方法关闭表单验证,非常感谢!
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 !
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 :)
composer require laravel/browser-kit-testing --dev
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()
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.
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!
Is there any chance to make a screenshot of a div with this package?
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.
$ 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.
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.
$this->json('GET', route('???'))
->seeJson()
->assertResponseOk();
I got error Undefined property when I run my test;
$this->visit('/')
Please check, if v5.x can run together with phpunit 9.x and update the requirements in composer.json if possible.
Add support for PHPUnit10.
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)
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
$this->expectsEvents([Foo::class]);
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.
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.
Laravel\BrowserKitTesting\TestCase
.php artisan test --parallel
.Each tab has a different form with same save button.
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
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
MakesHttpRequests::call() is annotated to return \Illuminate\Http\Response
, but it actually returns Laravel\BrowserKitTesting\TestResponse
.
It leads to warnings from static analysis tools such as PhpStAn
7.1
10.10
8.3
MySQL 8
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.
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.
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:
Run this to get the output above:
sh vendor/bin/sail php artisan test -p
Release 4.0.1 was tagged on March 14, there are 10 commits since then, could we tag 4.0.2 now?
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
Use assertion seeJsonStructure
with wildcard *
with library versions as above.
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)?
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:
Test:
$this->expectsJobs(...)
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
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
When I install and use this package, I no longer have access to assertions like:
And rather I'm forced to use assertResponseStatus which doesn't feel natural and asking me the leave the testing API that I already know.
This library seems to assume that people have mockery/mockery
defined as a project dependency. Currently I have to have it there only so that this library works. Please consider adding it as a real dependency.
https://github.com/laravel/browser-kit-testing/blob/master/src/Concerns/MocksApplicationServices.php#L5 is an example of where it is used.
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.
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';
}
Could we copy laravel/framework#30101 here?
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?
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
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!
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.
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?
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.
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.
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?
Thanks!
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
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.
Am I correct in saying this depends on symfony/dom-crawler? Specifically in the InteractsWithPages trait.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.