UnitTests how to get ID of created model or wipe DB each test?

So my current issue is that I hardcode the ID $response = $this->post(route('admin.books.store'), $attributes); $response->assertRedirect(route('admin....
rbur0425 rbur0425
11

Test Model From Job Class PHPUnit Mockery

How do I mock the markshipped method on the ebayOrders model? I am testing that the job handle() method works correctly. My current test the markshipped method still runs....
Testing
11
59
thomthom thomthom
4

DatabaseMigrations vs DatabaseTransactions

I have been using DatabaseMigrations with a in memory sqlite db for my tests on this project of mine. However, I need to switch to MySQL as I need some SQL features that sq...
Testing
4
471
marcel158 marcel158
0

Cypress E2E Tests to use the test database

I am using cypress.io for e2e testing. In my tests I am creating, updating and deleting data and this does all happen on the same database that I'm working with when I'm de...
Corbin Corbin
6

How do I test encrypted database fields?

I'm encrypting database fields using a custom Encryptable trait: Encryptable.php <?php namespace App; use Illuminate\Support\Faca...
untymage untymage
1

Assert json that have key value not in order

/** @test */ public function test_json() { $this->getJson(route('threads'))->assertJson([ 'data' => [ [...
valentinog valentinog
2

Testing a Laravel application with Cypress: 419 insufficient space on resource

I'm testing a Laravel application with Cypress. The test for the login page looks like this: describe("Knowledge Base...
Testing
2
295
spbaniya spbaniya
1

What is the best approach to do Unit/Feature Testing in Laravel

What is the best approach to do Unit/Feature Testing in following scenario? Have Authenticate Service on Lumen Have Messaging Service with API endpoin...
ilyavorozhbit ilyavorozhbit
1

Mock in feature test

Hi all! I'm writing a feature test, and in that test I need mock one method of some service, and then I need make $this->actingAs(...)->post(), which will use...
sohexaxok sohexaxok
1

Write test for resource

Hi, I have a resource for my API endpoint with a resource collection, but I want to test some logic for this resource collection. How can I write a test for this? Th...
sopeters sopeters
3

Tests for external functionality involving external system / apis

I'm trying to write tests for our some of our API that involves calls to external systems (e.g. for 2FA authentication). What's the best way to Mock those systems?....
tobyreed tobyreed
3

Set expiry of CSRF token in PHPUnit test

Hello, We have an issue in our PROD where users/we will get a 419 status code (CSRF token expired) from what I understand. I am trying to debug this and make a test...
Snowy Snowy
2

Laravel tests in VS Code

So I'm taking the course "Build A Laravel App With TDD". And Jeffrey somehow run single test by clicking on the name of the test. While i need t...
Tray2 Tray2
9

Thoughts about validation testing

I was thinking a bit about validation testing today and normaly I do something like this. I start with the happy path test. /** * @test */...
Testing
9
109
gbuckingham89 gbuckingham89
1

Testing notifications

I'm developing an application where the notifications are highly important, so want to get some good test coverage. I'm already using the Notification Fake (e.g....
fsilva1985 fsilva1985
4

Mockery_1_Illuminate_Console_OutputStyle::askQuestion(), but no expectations were specified

Hello. I have a problem with php-unit's job pipeline gilab. My local server its works very well. Anybody help me? Tnx .gitlab-ci.yml...
Testing
4
408
junaidqadir junaidqadir
1

The currently authenticated user is not who was expected

I'm using dusk and I can't figure out why is this test failing. When I dd the $student object it's populated. What am I missing here?...
Chris1981 Chris1981
0

Testing the Passport /oauth/token functionality

Hey Guys, I'm wondering if anyone has any examples of testing the Passport /oauth/token endpoint using the password grant type. I can't seem to find any examp...
Markk Markk
5

VScode phpunit test

Untill a while ago i could do the unit testing fine with shortcut which i assigned but now it only works if i manually type in the console php vendor/phpunit/phpunit/phpuni...
Testing
5
144
kennybjr87 kennybjr87
13

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...
Testing
13
2071
Samer_J Samer_J
10

Class 'Tests/TestCase' not found when attempting to run test

Can't find a solution to this anywhere. I've simply followed along with the Laravel 5.4 docs in the "Testing: Getting Started" section. I created a new tes...
Testing
10
1169
GlenUK GlenUK
7

Sharing model with all views via ASP breaks unit tests

Hello, Since I added the following to my AppServiceProvider.php class: public function boot() { View::share('stat...
Testing
7
143
dingo_d dingo_d
6

Test for user creation fails on validation

I have created a user creation screen and in my UserController I have a store method /** * Store a ne...
skoobi skoobi
2

Add rows to DB before running tests

Hi. I've got a test dataset in my local environment DB that has all the tables and data set up already, but I was wondering if there was a way that when I run a dusk...
MasterNag MasterNag
2

Factory : specifying different start values for auto incrementing field

Hi, I have the following factory defined : $factory->define(Video::class, function (Faker $faker) { static $order = 1; return [ 'ti...
Testing
2
142
hjortur17 hjortur17
11

Error while testing

I just created a new Laravel project and I get this when running my tests. Mockery\Exception\BadMethodCallException: Received Mockery_1_Illuminate_Console_Ou...
Testing
11
1166
xtremer360 xtremer360
3

Disabling Instance Property Casts

Currently, I've been doing some backfilling of back filling of test for my application and started writing some unit tests for my models. I have a test that is failing and...
Testing
3
107
yoeriboven yoeriboven
2

Removing a config entry for a test

I'm adding a feature to an existing package which will add a new config key/value. Current users don't have this item since this record doesn't exist yet. To make su...
Testing
2
132
ariatari ariatari
6

Laravel 6.5.1 Error: Call to undefined method assertDeleted()

Hi, I'm on Laravel Framework 6.5.1and when wanted to test for deleted record with $this->assertDeleted($table, array $data); got: Error: Call to undefined method...
Testing
6
274
GlenUK GlenUK
1

Get more infomation on test failure

Hello, I would like to know why this test failed: /** @test */ public function purchaseOrderAddedViaStoreMethod() { $this->withoutExceptionHand...
Testing
1
1280
mostafalaravel mostafalaravel
6

How to login then go to specific link to test ?

Hello , In my test I would like to login as user then get specific url status ! public function test_links() { $this->post('/logi...
Testing
6
199
mostafalaravel mostafalaravel
5

is it possible to test if all routes are redirected to login page when user is not logged-id ?

Hello , Here bellow I made a test to know if a non-loged user when he request / is redirected to the login page . the question is : this tes...
Testing
5
137
Saneesh Saneesh
0

InvalidArgumentException: Action Facade\Ignition\Http\Controllers\ExecuteSolutionController not defined.

I'm trying to do the Dusk testing. ViewAnotherUsersTweetsTest.php /** * @test */ public function can_view_another_user...
Testing
0
194
Benjamest Benjamest
1

PHPUnit sqlite and JSON fields

Hi all, I wish to write tests on a model which utilises the JSON field type. The test runs fine when utilising mysql or running the code in production however it is...
Testing
1
103
restran restran
6

Testing File Download with Dusk

Hey! I'm new using Dusk and I need to test the following case: I have a Download File button, when I click it a csv file is downloaded. Is there...
Testing
6
700
Create a New Discussion Button