/** * @covers phpDocumentor\Transformer\Router\ExternalRouter::__construct * @covers phpDocumentor\Transformer\Router\ExternalRouter::configure * @covers phpDocumentor\Transformer\Router\ExternalRouter::match */ public function testIfMultipleDefinitionsGenerateAnUrl() { // Arrange $config = new Configuration(); $config->getTransformer()->setExternalClassDocumentation(array(new ExternalClassDocumentation('My_Zen_Space', 'http://abc/zen/{CLASS}.html'), new ExternalClassDocumentation('My_Space', 'http://abc/{CLASS}.html'))); $router = new ExternalRouter($config); // Act $result = $router->match('My_Space_With_Suffix')->generate('My_Space_With_Suffix'); // Assert $this->assertSame('http://abc/My_Space_With_Suffix.html', $result); }
/** * Configuration function to add routing rules to a router. * * @return void */ public function configure() { $docs = $this->configuration->getTransformer()->getExternalClassDocumentation(); foreach ($docs as $external) { $prefix = (string) $external->getPrefix(); $uri = (string) $external->getUri(); $this[] = new Rule(function ($node) use($prefix) { return is_string($node) && strpos(ltrim($node, '\\'), $prefix) === 0; }, function ($node) use($uri) { return str_replace('{CLASS}', ltrim($node, '\\'), $uri); }); } }
/** * @covers phpDocumentor\Command\Helper\ConfigurationHelper::getOption * @covers phpDocumentor\Command\Helper\ConfigurationHelper::valueIsEmpty * @covers phpDocumentor\Command\Helper\ConfigurationHelper::getConfigValueFromPath */ public function testIfValueIsRetrievedFromConfigIfNotInInput() { // Arrange $optionName = 'myOption'; $inputMock = $this->givenAnInputObject(); $this->whenAnOptionIsRetrievedFromInput($inputMock, $optionName, null); // Act $result = $this->fixture->getOption($inputMock, $optionName, 'parser/defaultPackageName'); // Assert $this->assertSame($this->configuration->getParser()->getDefaultPackageName(), $result); }
/** * @covers phpDocumentor\Configuration::__construct * @covers phpDocumentor\Configuration::getTranslator */ public function testIfTranslatorConfigurationIsReturned() { $this->assertInstanceOf('phpDocumentor\\Translator\\Configuration', $this->fixture->getTranslator()); }