ControllerResolverTest.php 1.18 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
<?php

/**
 * @file
 * Definition of Drupal\system\Tests\Routing\ControllerResolverTest.
 */

namespace Drupal\system\Tests\Routing;

use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Request;

13
use Drupal\Core\Controller\ControllerResolver;
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
use Drupal\simpletest\UnitTestBase;

/**
 * Tests that the Drupal-extended ControllerResolver is functioning properly.
 */
class ControllerResolverTest extends UnitTestBase {

  public static function getInfo() {
    return array(
      'name' => 'Controller Resolver tests',
      'description' => 'Tests that the Drupal-extended ControllerResolver is functioning properly.',
      'group' => 'Routing',
    );
  }

  /**
   * Confirms that a container aware controller gets returned.
   */
  function testContainerAware() {
    $container = new Container();
    $resolver = new ControllerResolver($container);

    $request = Request::create('/some/path');
    $request->attributes->set('_controller', '\Drupal\system\Tests\Routing\MockController::run');

    $controller = $resolver->getController($request);

    $this->assertTrue($controller[0] instanceof MockController, 'The correct controller object was returned.');
  }
}