public function __construct(Container $container, $hosts, $routes)
 {
     $this->routes = new ArrayCollection();
     foreach ($routes as $key => $definition) {
         $route = new ExternalRoute(new Response(), new Request(), new Curl());
         $route->setHost($hosts[$definition['host']])->setURI($definition['uri'])->setMethod($definition['method']);
         if (!empty($definition['validation'])) {
             $validation = array();
             foreach ($definition['validation'] as $parameter => $validatorKey) {
                 $validation[$parameter] = $container["{$validatorKey}.validator"];
             }
             $route->setRules($validation);
         }
         $this->routes->set($key, $route);
     }
 }
 public function testBuildingEntityWithoutParameters()
 {
     $response = $this->getMockBuilder('Buzz\\Message\\Response')->getMock();
     $request = $this->getMockBuilder('Buzz\\Message\\Request')->getMock();
     $client = $this->getMockBuilder('Buzz\\Client\\Curl')->getMock();
     $entity = new ExternalRoute($response, $request, $client);
     $this->assertInstanceOf('Expressly\\Entity\\ExternalRoute', $entity->setMethod('GET'));
     $this->assertInstanceOf('Expressly\\Entity\\ExternalRoute', $entity->setHost('https://dev.expresslyapp.com/api/v2'));
     $this->assertInstanceOf('Expressly\\Entity\\ExternalRoute', $entity->setURI('/ping'));
     $this->assertInstanceOf('Expressly\\Entity\\ExternalRoute', $entity->setRules(array()));
     $this->assertInstanceOf('Expressly\\Entity\\ExternalRoute', $entity->setParameters(array()));
     $this->assertEquals('GET', $entity->getMethod());
     $this->assertEquals('https://dev.expresslyapp.com/api/v2', $entity->getHost());
     $this->assertEquals('/ping', $entity->getURI());
     $this->assertEquals('https://dev.expresslyapp.com/api/v2/ping', $entity->getURL());
     $this->assertEquals('https://dev.expresslyapp.com/api/v2/ping', (string) $entity);
     $this->assertInstanceOf('Buzz\\Message\\Response', $entity->process(function ($request) {
     }));
     $this->assertTrue($entity->isSuccessful());
 }