Exemplo n.º 1
0
 /**
  * @covers phpDocumentor\Transformer\Router\Rule::__construct
  * @covers phpDocumentor\Transformer\Router\Rule::generate
  */
 public function testIfUrlCanBeGenerated()
 {
     $fixture = new Rule(function () {
     }, function () {
         return 'url';
     });
     $this->assertSame('url', $fixture->generate('test'));
 }
 /**
  * @covers phpDocumentor\Transformer\Router\ForFileProxy::generate
  */
 public function testIfNullIsReturnedIfNodeDoesNotMatch()
 {
     // Arrange
     $this->ruleMock->shouldReceive('generate')->with('test')->andReturn(false);
     // Act
     $result = $this->fixture->generate('test', '\\');
     // Assert
     $this->assertFalse($result);
 }
Exemplo n.º 3
0
 /**
  * Generates an URL for the given node.
  *
  * @param string|DescriptorAbstract $node               The node for which to generate an URL.
  * @param string                    $directorySeparator Which directory separator should be used to generate the
  *     paths with, defaults to the default separator for the current O/S.
  *
  * @return string|false a well-formed relative or absolute URL, or false if no URL could be generated.
  */
 public function generate($node, $directorySeparator = DIRECTORY_SEPARATOR)
 {
     $webserverPath = $this->rule->generate($node);
     return $webserverPath === false ? false : str_replace('/', $directorySeparator, $webserverPath);
 }