LaravelGeneratorTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Knuckles\Scribe\Tests\Unit;
  3. use Illuminate\Routing\Route;
  4. use Illuminate\Support\Facades\Route as RouteFacade;
  5. use Knuckles\Scribe\ScribeServiceProvider;
  6. use Knuckles\Scribe\Tests\Fixtures\TestController;
  7. class LaravelGeneratorTest extends GeneratorTestCase
  8. {
  9. protected function getPackageProviders($app)
  10. {
  11. return [
  12. ScribeServiceProvider::class,
  13. ];
  14. }
  15. public function createRoute(string $httpMethod, string $path, string $controllerMethod, $register = false, $class = TestController::class)
  16. {
  17. if ($register) {
  18. return RouteFacade::{$httpMethod}($path, $class . "@$controllerMethod");
  19. } else {
  20. return new Route([$httpMethod], $path, ['uses' => $class . "@$controllerMethod"]);
  21. }
  22. }
  23. public function createRouteUsesArray(string $httpMethod, string $path, string $controllerMethod, $register = false, $class = TestController::class)
  24. {
  25. if ($register) {
  26. return RouteFacade::{$httpMethod}($path, [$class . "$controllerMethod"]);
  27. } else {
  28. return new Route([$httpMethod], $path, ['uses' => [$class, $controllerMethod]]);
  29. }
  30. }
  31. public function createRouteUsesCallable(string $httpMethod, string $path, callable $handler, $register = false)
  32. {
  33. if ($register) {
  34. return RouteFacade::{$httpMethod}($path, $handler);
  35. } else {
  36. return new Route([$httpMethod], $path, ['uses' => $handler]);
  37. }
  38. }
  39. }