trevorpan trevorpan
0

access $variable property in test method

Have been working on this test for a while with help from a previous post. I'm really happy to get the paymentGateway working after a few days by myself without post...
Mindexperiment Mindexperiment
2

Download file from resources path

Hi all, I'm testing the file download from a resource path. I need to provide to users a template illustrator file to work with. The test to be passed:...
AmirrezaN AmirrezaN
1

Should I write tests for middleware existence on routes?

Should we write tests to see if a specific middleware is being executed on route (groups)? I'm not talking about the middleware functionality since most of them are...
KiberMath KiberMath
1

How to configure PHPStorm to run PHPUnit tests in docker

Hello. I have server with docker on it. On the server i have compose.yaml with services i need for my app. And now if i want to run a test I can go to server, then "d...
nashan nashan
3

Build Laravel App with TDD Series 2 Testing issue

When running phpunit in command prompt following warning appear PHPUnit 7.5.14 by Sebastian Bergmann and contributors. W...
drewdan drewdan
0

Asserting Policy is Present

Hey Guys, I am currently writing lots of tests and I have a question around assertions. In most of our controllers, we are starting to use policies...
minhajul minhajul
4

MySQL functions are not supported in SQLite!

I am using MySQL as my primary database and SQLite for testing. Some of the MySQL functions like YEAR, MONTH etc is not supported by SQLite. How you guys are dealing with t...
dani94 dani94
1

Problem creating factory from a Model with custom constructor

Im created few unit testing, they works! But after refactor my Order Model creating custom constructor. This is my Order Model constructor:...
jred-lewis jred-lewis
2

Slug Validation

I'm looking to add slugs to a model in my Laravel project. If the slug field isn't present in the store method, I want it to set a default value based on its title....
danielcoker danielcoker
10

How to use env in Laravel package?

I'm contributing to a Laravel package, and I need to use the env() function to get the APP_NAME. But when I run the test, I get the error "call to undefined function e...
Testing
10
165
nexxai nexxai
5

Storage::assertMissing failing; file is actually gone in real life

I have this test: public function deletingAStudioResultsInTheLogoBeingDeleted() { $this->signIn(); Storage::fake...
Bahjaat Bahjaat
4

PHPUNIT fails, but separate testsuits not

I'm really struggling with my tests. Look's like the 'RefreshDatabase' is not working like I expect. I am using a mysql test database. When the test is failing more records...
Testing
4
246
sanjitsingh sanjitsingh
2

RefreshDatabase not rolling back the transaction after running test

Hi there, I am using mysql as a testing database. I am trying to rollback the changes after each test using RefreshDatabase trait but it is not working....
nexxai nexxai
3

How to Storage::fake() an entire set of tests

I have a class that an uploaded file is required and so I've added the UploadedFile::fake() to the factory, but I really don't want to be uploading actual files to the host...
MarkTierney MarkTierney
7

Can I mock an object used inside an Eloquent model?

I have a 'Contact' eloquent model with an 'Geolocation' object dependency. Is there a way to Mock the Geolocation model? I thought I could just inject this into the...
martyyy martyyy
3

Laravel phpunit testing missing functions

I just update my Laravel to 5.8 from 5.2 and my functional tests stoped working. I search a lot of topics on google about this problem but I just can find a function...
ThePoet444 ThePoet444
10

testing that a user can edit profile

Simple enough situation, a user can edit their own profile. Run it through a browser test, works like a charm. Make a test for it... well now we have something interesting....
Testing
10
164
petritr petritr
5

unit test relations

I have complex relations, witch is the best way to test relations ? Any best practice examples ?...
trevorpan trevorpan
6

findOrFail($jobId); returns 404 but test creates $job

error: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: POST htt...
Testing
6
124
catsedawk catsedawk
2

testing: RefreshDatabase trait with seeder (for every single test)

I am trying to use the 'RefreshDatabase' trait. What I'm looking for is that for every test the db is migrated fresh and then seeded with some vital rows. If...
untymage untymage
2

Assert Redirect for all routes that have specific prefix

is there a method that asserting group of routes that have specific prefix? for example: $this->get('admin/index')->assertRedirec...
pedroroccon pedroroccon
10

PHPUnit returning 404 after first GET request

Greetings! I'm getting an error 404 in my PHPUnit Tests. After doing my first GET Request, every next requests returns a 404 error. To make easier to understand, I m...
Testing
10
201
BrownieCoffee BrownieCoffee
5

unexpected errors for my test

Hello, I on my tests yet and I have unexpected errors. ............ 23 / 23 (100%) Time: 30.1 seconds, Memo...
Testing
5
151
BrownieCoffee BrownieCoffee
14

Session has unexpected errors:

Hello, I have a problem with my test. There are duplication of datas and I don't know why. I have these error below : F...............
Testing
14
243
bigweld86 bigweld86
1

Why the response from the same endpoint is different

While unit-testing a method from my RegisterController I noticed that it responds back differently depending on the method use to make the request. So if I perform t...

Returning paginated results from a mocked repository

View is failing to render because of what is returned from my mocked repository which makes the test fail. It works fine if I replace mocking with factory that adds entries...
Danieloplata Danieloplata
9

Relationship returns empty in tests

Hi guys, I'm trying to test a route in one of my projects, which has a bit of middleware that checks the user's country. My test is failing because the relationship...
Testing
9
135
NikkiLoveGod NikkiLoveGod
6

How to display exceptions in PHPUnit?

Hi, So I'm using Laravel 5 and I tried to do TDD with PHPUnit, but got stumped right at the beginning with the workflow. I want to test that my route is OK, so I cre...
Testing
6
1140
alhoqbani alhoqbani
3

Changing default disk for testing.

I'm trying to build a test for images handling in my application. For the database testing I'm using DatabaseMigrations, so the test persists records in sqlite memory and t...
Testing
3
1347
Oldenborg Oldenborg
10

Testing if email was sent with out sending it

Im writing an acceptance test to check if the built in "reset password" functionality is working properly. How do I test if the mail is being triggered and sent w...
Testing
10
3870
jonassiewertsen jonassiewertsen
3

CircleCI vs. Travis Ci

Do you prefer CircelCi or Travis Ci and why?...
Testing
3
114
NathanIsaac NathanIsaac
15

PHPUnit Test Setting Cookies

// Routes Route::get('set-cookie', function() { return redirect('view-cookie')->withCookie(cookie('test', 'hello')); }); Route::get('vi...
Testing
15
2193
BrownieCoffee BrownieCoffee
10

Column not found: 1054 Unknown column 'project_id' in 'field list'

Hi. I have this error after running phpunit: ..........E............ 23 / 23 (100%) Time: 24.6...
Testing
10
170
eugenevdm eugenevdm
1

Best practice testing JSON API response codes when using Queueing

I'm using APIs to do most of the heavy lifting in my application. I'm trying to stick with best practices, e.g. I have Unit and Feature tests, lean controllers, using depen...
BrownieCoffee BrownieCoffee
1

Problem to display array with polymorphic relation

Hello everyone. I have a problem to display the post and the relations with its relations. I wrote this code : //my test: $project = fa...
Create a New Discussion Button