Home > database >  How create RouteCollectionBuilderTest.php in vendor/symfony/routing/Tests in laravel
How create RouteCollectionBuilderTest.php in vendor/symfony/routing/Tests in laravel

Time:01-07

I follow one project to make practice my laravel skill. I found one thing is this project make admin route in RouteCollectionBuilderTest file that located in symfony/routing/Tests folder. this Tests folder is not present in original laravel folder structure. what logic make this Tests folder ,is this API testing? enter image description here

by this $routes->add('/admin', 'AppBundle:Admin:dashboard', 'admin_dashboard'); admin route can redirect by http://localhost:8000/admin I want to know is how can make this logic . here is all files that incude in Test folder enter image description here

I want to know how to make this files and why this files need in project

CodePudding user response:

You are seeing tests for the symfony/routing Composer package. These are tests specific to the Routing package, unrelated to Laravel.

Usually these files can be excluded in the package export by using the export-ignore flag in a .gitattributes file (example in symfony/routing). This export with exclusion happens when you use the --prefer-dist option in Composer.

If you use --prefer-source or a similar configuration, or if you did a git clone directly, these test files will still be included.

You don't want to depend on those test files for your own application tests. Instead, read about Laravel's HTTP testing options for asserting your route functionality.

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function test_a_basic_request()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}
  •  Tags:  
  • Related