/**
  * @test
  * it should allow passing a filter and an anonymous function as callback
  */
 public function it_should_allow_passing_a_filter_and_an_anonymous_function_as_callback()
 {
     $path = 'some';
     $id = 'some';
     $callback = function () {
     };
     $args = array('path' => '^some$', 'page_callback' => array('GET' => $callback), 'template' => false, 'access_callback' => array('GET' => 'phpcredits'));
     $this->router->expects($this->once())->method('add_route')->with($id, $args);
     $this->sut->hook();
     WPRouting_Route::filter('filter', 'phpcredits');
     $this->sut->_get($path, array('filter', $callback));
     $this->sut->__destruct();
     WPRouting_Route::generateRoutes($this->router);
 }
 /**
  * Sets the `permalink` key for the route starting from the path.
  *
  * A `path` specified in the route like `/^hello$/` will set the route permalink to `hello`.
  *
  * @param $patterns
  */
 protected function replacePatterns($patterns)
 {
     // call WPRouting_Route::replacePatterns
     parent::replacePatterns($patterns);
     // set the permalink to something like path
     // do not use the '/'
     if (!isset($this->args['path'])) {
         return;
     }
     $this->args['permalink'] = rtrim(ltrim($this->args['path'], '/^'), '$/');
 }