MakeViewVariableOptionalSolutionTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Facade\Ignition\Tests\Solutions;
  3. use Facade\Ignition\Solutions\MakeViewVariableOptionalSolution;
  4. use Facade\Ignition\Support\ComposerClassMap;
  5. use Facade\Ignition\Tests\TestCase;
  6. use Illuminate\Support\Facades\View;
  7. class MakeViewVariableOptionalSolutionTest extends TestCase
  8. {
  9. public function setUp(): void
  10. {
  11. parent::setUp();
  12. View::addLocation(__DIR__.'/../stubs/views');
  13. $this->app->bind(
  14. ComposerClassMap::class,
  15. function () {
  16. return new ComposerClassMap(__DIR__.'/../../vendor/autoload.php');
  17. }
  18. );
  19. }
  20. /** @test */
  21. public function it_does_not_open_scheme_paths()
  22. {
  23. $solution = $this->getSolutionForPath('php://filter/resource=./tests/stubs/views/blade-exception.blade.php');
  24. $this->assertFalse($solution->isRunnable());
  25. }
  26. /** @test */
  27. public function it_does_open_relative_paths()
  28. {
  29. $solution = $this->getSolutionForPath('./tests/stubs/views/blade-exception.blade.php');
  30. $this->assertTrue($solution->isRunnable());
  31. }
  32. /** @test */
  33. public function it_does_not_open_other_extentions()
  34. {
  35. $solution = $this->getSolutionForPath('./tests/stubs/views/php-exception.php');
  36. $this->assertFalse($solution->isRunnable());
  37. }
  38. protected function getSolutionForPath($path): MakeViewVariableOptionalSolution
  39. {
  40. return new MakeViewVariableOptionalSolution('notSet', $path);
  41. }
  42. }