/**
  * Make sure the setter can transform string to array and set correct attribute
  *
  * @covers phpDocumentor\Parser\Parser::setVisibility
  * @covers phpDocumentor\Parser\Parser::getVisibility
  *
  * @return void
  */
 public function testSetVisibilityCorrectlySetsAttribute()
 {
     $visibility = array('public', 'protected', 'private');
     $this->fixture->setVisibility(implode(',', $visibility));
     $this->assertAttributeEquals($visibility, 'visibility', $this->fixture);
     $this->assertEquals($visibility, $this->fixture->getVisibility());
 }
 /**
  * Tests whether the getMarker() and setMarkers methods function
  * properly.
  *
  * @covers phpDocumentor\Parser\Parser::setMarkers
  * @covers phpDocumentor\Parser\Parser::getMarkers
  *
  * @return void
  */
 public function testMarkers()
 {
     $fixture_data = array('FIXME', 'TODO', 'DOIT');
     // default is TODO and FIXME
     $this->assertEquals(array('TODO', 'FIXME'), $this->fixture->getMarkers());
     $this->fixture->setMarkers($fixture_data);
     $this->assertEquals($fixture_data, $this->fixture->getMarkers());
 }
 public function populate(Parser $parser, InputInterface $input, ConfigurationHelper $configurationHelper, Collection $files)
 {
     $parser->setForced($input->getOption('force'));
     $parser->setEncoding($configurationHelper->getOption($input, 'encoding', 'parser/encoding'));
     $parser->setMarkers($configurationHelper->getOption($input, 'markers', 'parser/markers', array('TODO', 'FIXME'), true));
     $parser->setIgnoredTags($input->getOption('ignore-tags'));
     $parser->setValidate($input->getOption('validate'));
     $parser->setDefaultPackageName($configurationHelper->getOption($input, 'defaultpackagename', 'parser/default-package-name'));
     $parser->setPath($files->getProjectRoot());
 }
Beispiel #4
0
 /**
  * Returns the filename, relative to the root of the project directory.
  *
  * @param string $filename The filename to make relative.
  *
  * @throws \InvalidArgumentException if file is not in the project root.
  *
  * @return string
  */
 public function getRelativeFilename($filename)
 {
     // strip path from filename
     $result = ltrim(substr($filename, strlen($this->parser->getPath())), DIRECTORY_SEPARATOR);
     if ($result === '') {
         throw new \InvalidArgumentException('File is not present in the given project path: ' . $filename);
     }
     return $result;
 }
 /**
  * @param $forced
  */
 protected function initializeParserWithDefaultVariables($forced)
 {
     $this->parserMock->shouldReceive('getDefaultPackageName')->andReturn('default');
     $this->parserMock->shouldReceive('doValidation')->andReturn(false);
     $this->parserMock->shouldReceive('getEncoding')->andReturn('utf-8');
     $this->parserMock->shouldReceive('getMarkers')->andReturn(array('TODO', 'FIXME'));
     $this->parserMock->shouldReceive('isForced')->andReturn($forced);
     $this->parserMock->shouldReceive('getPath')->andReturn(__DIR__);
 }
 /**
  * Registers services on the given app.
  *
  * @param Application $app An Application instance
  *
  * @throws Exception\MissingDependencyException if the Descriptor Builder is not present.
  *
  * @return void
  */
 public function register(Application $app)
 {
     if (!isset($app['descriptor.builder'])) {
         throw new Exception\MissingDependencyException('The builder object that is used to construct the ProjectDescriptor is missing');
     }
     $app['parser'] = $app->share(function ($app) {
         $parser = new Parser();
         $parser->setStopwatch($app['kernel.stopwatch']);
         $parser->setLogger($app['monolog']);
         return $parser;
     });
     $app['markdown'] = $app->share(function () {
         return \Parsedown::instance();
     });
     /** @var Translator $translator  */
     $translator = $app['translator'];
     $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');
     $app['parser.files'] = new Collection();
     $app->command(new ParseCommand($app['descriptor.builder'], $app['parser'], $translator, $app['parser.files']));
 }
 /**
  * Make sure the setter can transform string to array and set correct attribute
  *
  * @covers \phpDocumentor\Parser\Parser::setVisibility
  *
  * @return void
  */
 public function testSetVisibilityCorrectlySetsAttribute()
 {
     $this->fixture->setVisibility('public,protected,private');
     $this->assertAttributeEquals(array('public', 'protected', 'private'), 'visibility', $this->fixture);
 }
 /**
  * @covers phpDocumentor\Parser\Parser::setDefaultPackageName
  * @covers phpDocumentor\Parser\Parser::getDefaultPackageName
  */
 public function testSetAndGetDefaultPackageName()
 {
     $parser = new Parser();
     $this->assertEquals('Default', $parser->getDefaultPackageName());
     $parser->setDefaultPackageName('test');
     $this->assertSame('test', $parser->getDefaultPackageName());
 }