Doubt with PHPUnit Test-unit

1

I'm starting with PHPUnit, I'm implementing the first tests in my applications, but I have the following doubt.

Should all classes really be tested, or are there any exceptions, if so what are they?

For example. I have an MVC framework that implements a route system with the following classes:

abstract class Bootstrap
{
    private $routes;

    public function __construct()
    {
        $this->initRoutes();
        $this->run($this->getUrl());
    }

    abstract protected function initRoutes();

    protected function run($url)
    {
        array_walk($this->routes, function($route) use ($url){
            if($url == $route['route']){
                $class = "App\Controllers\".ucfirst($route['controller']);
                $controller = new $class;
                $action = $route['action'];
                $controller->$action();
            }
        });
    }

    protected function setRoutes(array $routes)
    {
        $this->routes = $routes;
    }

    protected function getUrl()
    {
       return parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    }
}

and ...

class Route extends Bootstrap
{
    protected function initRoutes()
    {
        $routes['home'] = array(
            'route'     =>'/',
            'controller'=>'indexController',
            'action'    =>'index'
        );

        // Mais rotas..

        $this->setRoutes($routes);
    }
}

Do these classes really need to be tested? If so, how can I implement these tests? Any examples? Something you can read? I researched a lot but I did not find anything that would solve this doubt.

    
asked by anonymous 29.06.2017 / 20:14

0 answers