<?php
namespace Concrete\Tests\Core\Routin;

use PHPUnit_Framework_TestCase;
use Concrete\Core\Support\Facade\Application;

class CheckRoutesTest extends PHPUnit_Framework_TestCase
{
    public function routeDestinationProvider()
    {
        $app = Application::getFacadeApplication();
        $config = $app->make('config');
        $routes = $config->get('app.routes');
        $result = [];
        foreach ($routes as $path => $data) {
            if (is_array($data) && isset($data[0]) && is_string($data[0]) && $data[0] !== '') {
                $result[] = [$path, $data[0]];
            }
        }

        return $result;
    }

    /**
     * @dataProvider routeDestinationProvider
     */
    public function testRouteDestination($path, $callable)
    {
        if (preg_match('/^(.+)::(__construct)$/', $callable, $m)) {
            $this->assertTrue(class_exists($m[1], true), "Invalid route for path $path: $callable");
        } else {
            $this->assertTrue(is_callable($callable), "Invalid route for path $path: $callable");
        }
    }
}

Check that all route destinations are callable
Check that all route destinations are callable


Former-commit-id: a007b9215e3fa2bc6ba1555a6f605205083f5f38
Former-commit-id: bf458d7e6540b1089a545501ea5a32e4b8e5da9c