WebTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Tests\Routes;
  3. use App\User;
  4. use Illuminate\Support\Str;
  5. use Tests\TestCase;
  6. class WebTest extends TestCase
  7. {
  8. const PARAM = 1;
  9. const GET = [
  10. "/home",
  11. "/homeTemp",
  12. "password/change",
  13. "password/update",
  14. ];
  15. const POST = [
  16. ];
  17. const PUT = [
  18. ];
  19. const DELETE = [
  20. ];
  21. const RESTFUL = [
  22. ];
  23. const ANY = [
  24. ];
  25. const MATCH = [
  26. ];
  27. public function testRoutes(){
  28. $superAdmin = config('users.superAdmin');
  29. $user = User::query()->where('name',$superAdmin[0])->first();
  30. if (!$user){
  31. $user = User::query()->create([
  32. 'name' => $superAdmin[0],
  33. 'email' => "test@example.com",
  34. 'password' => "$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi",
  35. 'remember_token' => Str::random(10),
  36. ]);
  37. }
  38. $getMethod = self::GET;
  39. $postMethod = self::POST;
  40. $putMethod = self::PUT;
  41. $deleteMethod = self::DELETE;
  42. foreach (self::MATCH as $method => $route){
  43. if ($method == 'get'){
  44. array_push($getMethod,$route);
  45. }
  46. if ($method == 'post'){
  47. array_push($postMethod,$route);
  48. }
  49. if ($method == 'put'){
  50. array_push($putMethod,$route);
  51. }
  52. if ($method == 'delete'){
  53. array_push($deleteMethod,$route);
  54. }
  55. }
  56. $urls = array_merge(self::GET,self::RESTFUL);
  57. /** @var User $user */
  58. foreach ($urls as $url){
  59. $response = $this->actingAs($user)->get($url);
  60. $this->assertNotEquals($response->getStatusCode(),404);
  61. }
  62. }
  63. public function testPost(){
  64. }
  65. }