Laravel Testing Migrating Pollutes Assertions
While writing tests for my Laravel package I came across something strange. My empty tests were passing instead of marked as "Risky".
Further investigation led me to the PendingCommand
class that has a run()
method which makes an assertion on the exit code of the command. This PendingCommand
was instantiated by calling $this->astisan('migrate:fresh')->run()
. I was able to skip this assertion by calling assertExitCode(null)
before running the command. It worked but there is still an assertion happening.
Anybody had this problem before and/or was able to prevent assertions from happening before the actual test is executed?
It would be nice to see which assertions are being made, but I was unable to find this. The only thing I could find was that the Assert
class keeps a $count
of all the assertions done, not which one.
I will continue my search for a solution and post my findings to this question.
Answer
Found out that InteractsWithConsole
has a withoutMockingConsoleOutput
method that will prevent a mock to be created with assertions.
Final code:
$this->withoutMockingConsoleOutput()
->artisan('migrate:fresh');
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms