mohammadbasir mohammadbasir
2

Form validation php unit testing

I want to test form validation in the unit test. Here is my code. I don't know why it is not working. public function a_username_field_is_required_to_update_...
behrooznik behrooznik
9

why this test is not working?

this is my test: public function a_user_can_unfollow_others() { $ali=$this->SignIn(); $behrooz=factory(User::class)->create();...
bjenkins24 bjenkins24
1

$this->partialMock doesn't call the constructor?

I guess this is how partialMock works? But to me it seems to be useless now. There's a method I want to mock in a class, but the constructor has to be called or ev...
timroush timroush
3

Manually Seed RefreshDatabase

I'm running some migrations with SQLite, and my tests are using the RefreshDatabase trait. I also have seeders (registered in the DatabaseSeeder.php file) that should seed...
Testing
3
388
behrooznik behrooznik
1

what is the problem of this test?

after running the following test i got this Error: Failed asserting that actual size 0 matches expected size 1. this is my test: public function a_user...
tykus replied
Solved
jeromesoriano jeromesoriano
2

Factory + Create First 3 Records as System and Admins

I am using tinker to populate records of Agents. Tinker command below: User::factory()->count(10)->create(); But I wanted the first 3 recor...

Running tests get Uncaught Illuminate\Contracts\Container\BindingResolutionException

hi, when i run a test i get following error PHPUnit_Framework_Exception: PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionExcep...
Testing
5
2118
automica automica
6

AssertSeeInElement

I'm currently working on an improvement to a store which involves me writing some tests to check a site navigation works. Currently the site has a main navigation th...
XiaTesting XiaTesting
1

why assertJson not working what I expect

In my controleller I have: public function index() { $category = Category::all(); return response()->json([ 'data' => $category,...
deligoez deligoez
4

Laravel 8 Factories: Access overriden attributes from definition()

How we can directly access overriden attributes (array $attributes) in a Laravel 8 factory definition() method? Let's say for this given L7...
Testing
4
181
EckyEckyPtang EckyEckyPtang
10

Laravel 8: phpunit giving error on test

Since today, when running phpunit tests, I get: Illuminate\Contracts\Container\BindingResolutionException: Target class [DatabaseSeeder] does not exist....
Testing
10
223
TobiasS TobiasS
5

Test assertStatus(403) fails when $this->withoutExceptionHandling();

Hi! I get an error, This action is unauthorized. when $this->withoutExceptionHandling(); is in the test. Any ideas why? TEST: test('Boss ca...
tykus replied
Solved
kennybjr87 kennybjr87
14

RuntimeException: No application encryption key has been specified 5.8

I downloaded a brand new install of laravel 5.8 before even doing any coding at all running phpunit on the ExampleTest is failing with a RuntimeException: No application en...
worgor replied
Solved
Testing
14
8803
connecteev connecteev
2

access base_path() from within a unit test?

Trying to call base_path from setupBeforeClass() php artisan test --filter=PaymentsAndSubscriptionsTest public static function setUpBeforeClass():...
DaniloPolani DaniloPolani
3

Mocking Response

Hello, I have a utility class that, from a given input, returns a response()->json() instance. I'd love to test it, but of course from a Unit test it...
t0berius t0berius
17

laravel factory relation

Is there a way to create related models from arrays for a hasMany relation inside laravel model factories? CategoryTableSeeder: $categori...
Testing
17
295
t0berius t0berius
2

Class 'Database\Factories\UserFactory' not found / laravel Factory

Using factories the first time: database/factories/UserFactory.php namespace Database\Factories; use App\User; use Illuminate\Database\Eloquent\Facto...
Testing
2
231
Neeraj1005 Neeraj1005
7

Expected status code 200 but received 500. Failed asserting that 200 is identical to 500.

In my project I'm trying to write a test for category resource route. Wher auth middleware make a problem. In my project I have 3 roles superadmin...
Neeraj1005 Neeraj1005
9

could not find driver (SQL: PRAGMA foreign_keys = ON;)

In my project I'm trying to make test cases but it throw me some this kind of error. can anyone tells me whats the problem with this. Basically I'm using the system w...
Testing
9
116
untymage untymage
3

Opposite of Http:fake() ?

i have multiple tests that uses Http:fake() so i never make real request to an api endpoint, But sometimes i wanna make sure my codes actually work with the re...
Testing
3
108
XiaTesting XiaTesting
2

How to test I get the same number of categories as same as the database

Here is my test, I use factory first to create some categories, then hit the endpoint /categories , but I don't know how to test if I get the same number of categories, an...
Testing
2
173
strawberry strawberry
6

phpunit not using in memory sqlite

Hi, I've just started the 'Let's Build A Forum with Laravel and TDD' series, and am unable to get the tests running using the sqlite in memory database. Using Laragon if th...
Testing
6
146
untymage untymage
3

Http::fake() for strings ?

I want to pass string to fake method but i get error : Http:fake(fn() => 'some data in string');...
tykus replied
Solved
wesleya wesleya
8

Testing job dispatch in Laravel

Is there a way to test that a job is dispatched with the correct parameters in Laravel phpunit? For example, I have a job that searches for images that should be deleted. F...
Testing
8
11175
VinayKesharwani VinayKesharwani
2

Test failed when running queries in Service Provider

Is running db query in service provider a bad practice? For example, I want to have configuration (stored in the database) set & available everywhere via service provid...
Testing
2
113
gianmarx gianmarx
0

test payment automatic Cypress

i have this problem with test cypress:...
r123 r123
14

Laravel Dusk ignoring testing database and uses main one instead

When I run my Dusk tests it uses my main database instead of one I created for testing. What am I doing wrong here? I did clear config cache after setting TESTS_DB environm...
Testing
14
1185
XiaTesting XiaTesting
1

How to test to "delete multiple records"

Hi guys, recently I really enjoy test before code, however, I have a problem here: I want to test delete multiple records according to id(array), here is my test:...
Testing
1
105
majebry majebry
1

Mocking a FormRequest

Hi, I was following this guide in order to "mock" a FormRequest:...
supertrall supertrall
16

Laravel ignores the testing connection

I have a big and complex mysql-based schema and I want to use an in-memory sqlite database for testing using migrations for cleaning up as it's said here:...
alaame replied
Solved
Testing
16
3279
gianmarx gianmarx
0

Cypress problems take value and compare it. Scope variable

I have this HTML structure: <tr id="post-7053" class="iedit author-other level-0 post-7053 type-poi status-publish hentry webmapp_category-...
zaster zaster
2

TDD - Avoids upfront database planning ?

I am new to TDD and as i understood we can avoid the traditional way of planning the entire database and proceed with coding, if we continue with the TDD approach. C...
Testing
2
101

Laravel unable to read embedded file during unit test on gitlab ci

Hi laracast, first of all .. I'm very sorry for my rusty english. :D I've been playing around with setting up my unit test for 2 days now, but I'm unable to e...
XiaTesting XiaTesting
1

How to fix testing error, there is no driver.

Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA foreign_keys = ON;) C:\xampp\htdocs\blog\vendor\laravel\framework\src\Illuminate\Database\Conn...
Testing
1
133
gianmarx gianmarx
1

Test Mail laravel 8x

about this episode: https://laracasts.com/series/php...
Create a New Discussion Button