LaravelGeneratorTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. $providers = [
  12. ScribeServiceProvider::class,
  13. ];
  14. if (class_exists(\Dingo\Api\Provider\LaravelServiceProvider::class)) {
  15. $providers[] = \Dingo\Api\Provider\LaravelServiceProvider::class;
  16. }
  17. return $providers;
  18. }
  19. public function createRoute(string $httpMethod, string $path, string $controllerMethod, $register = false, $class = TestController::class)
  20. {
  21. if ($register) {
  22. return RouteFacade::{$httpMethod}($path, $class . "@$controllerMethod");
  23. } else {
  24. return new Route([$httpMethod], $path, ['uses' => $class . "@$controllerMethod"]);
  25. }
  26. }
  27. public function createRouteUsesArray(string $httpMethod, string $path, string $controllerMethod, $register = false, $class = TestController::class)
  28. {
  29. if ($register) {
  30. return RouteFacade::{$httpMethod}($path, [$class . "$controllerMethod"]);
  31. } else {
  32. return new Route([$httpMethod], $path, ['uses' => [$class, $controllerMethod]]);
  33. }
  34. }
  35. public function createRouteUsesCallable(string $httpMethod, string $path, callable $handler, $register = false)
  36. {
  37. if ($register) {
  38. return RouteFacade::{$httpMethod}($path, $handler);
  39. } else {
  40. return new Route([$httpMethod], $path, ['uses' => $handler]);
  41. }
  42. }
  43. }