/**
  * Method to test match().
  *
  * @param string  $url
  * @param string  $pattern
  * @param string  $method
  * @param boolean $expected
  * @param integer $line
  *
  * @return void
  *
  * @covers       Windwalker\Router\Route::match
  *
  * @dataProvider matchCases
  */
 public function testMatch($url, $pattern, $method, $expected, $line)
 {
     $uri = new Uri($url);
     $host = $uri->getHost();
     $scheme = $uri->getScheme();
     $port = $uri->getPort() ?: 80;
     $config = array('name' => 'flower', 'pattern' => $pattern, 'variables' => array('_controller' => 'FlowerController', 'id' => 1), 'method' => array('GET', 'PUT'), 'host' => 'windwalker.com', 'scheme' => 'http', 'port' => 80, 'sslPort' => 443, 'requirements' => array('id' => '\\d+'));
     $route = new \Windwalker\Router\Route($config['name'], $config['pattern'], $config['variables'], $config['method'], $config);
     $result = $this->instance->setRoutes(array($route))->match($uri->getPath(), $method, array('host' => $host, 'scheme' => $scheme, 'port' => $port));
     $this->assertEquals($expected, !empty($result), 'Match fail, case on line: ' . $line);
 }
示例#2
0
 /**
  * Test the setPath method.
  *
  * @return  void
  *
  * @since   1.0
  * @covers  Windwalker\Uri\Uri::setPath
  */
 public function testSetPath()
 {
     $this->object->setPath('/this/is/a/path/to/a/file.htm');
     $this->assertThat($this->object->getPath(), $this->equalTo('/this/is/a/path/to/a/file.htm'));
 }