RunningLaravelDuskInProductionSolutionProviderTest.php 1.3 KB

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace Facade\Ignition\Tests\Solutions;
  3. use Exception;
  4. use Facade\Ignition\SolutionProviders\RunningLaravelDuskInProductionProvider;
  5. use Facade\Ignition\Tests\TestCase;
  6. class RunningLaravelDuskInProductionSolutionProviderTest extends TestCase
  7. {
  8. /** @test */
  9. public function it_can_solve_dusk_in_production_exception()
  10. {
  11. $exception = $this->generate_dusk_exception();
  12. $canSolve = app(RunningLaravelDuskInProductionProvider::class)->canSolve($exception);
  13. [$first_solution, $second_solution] = app(RunningLaravelDuskInProductionProvider::class)->getSolutions($exception);
  14. $this->assertTrue($canSolve);
  15. $this->assertSame($first_solution->getSolutionTitle(), 'Laravel Dusk should not be run in production.');
  16. $this->assertSame($first_solution->getSolutionDescription(), 'Install the dependencies with the `--no-dev` flag.');
  17. $this->assertSame($second_solution->getSolutionTitle(), 'Laravel Dusk can be run in other environments.');
  18. $this->assertSame($second_solution->getSolutionDescription(), 'Consider setting the `APP_ENV` to something other than `production` like `local` for example.');
  19. }
  20. private function generate_dusk_exception(): Exception
  21. {
  22. return new Exception('It is unsafe to run Dusk in production.');
  23. }
  24. }