Ejemplo n.º 1
0
 /**
  * Tests whether the generateFilename method returns a file according to
  * the right format.
  *
  * @return void
  */
 public function testGenerateFilename()
 {
     // separate the directories with the DIRECTORY_SEPARATOR constant to
     // prevent failing tests on windows
     $filename = 'directory' . DIRECTORY_SEPARATOR . 'directory2' . DIRECTORY_SEPARATOR . 'file.php';
     $this->assertEquals('db_directory_directory2_file.html', $this->fixture->generateFilename($filename));
 }
Ejemplo n.º 2
0
 public function testExecuteTransform()
 {
     touch('/tmp/docblox_a');
     @unlink('/tmp/docblox_b');
     $this->assertFileExists('/tmp/docblox_a');
     $this->assertFileNotExists('/tmp/docblox_b');
     $tr = new DocBlox_Transformer();
     $tr->setTarget('/tmp');
     try {
         $t = new DocBlox_Transformer_Transformation($tr, 'copyz', 'FileIo', '/tmp/docblox_a', 'docblox_b');
         $this->fixture->transform(new DOMDocument(), $t);
         $this->fail('When un unknown query type is used an exception is expected');
     } catch (InvalidArgumentException $e) {
         // this is good
     }
     $t = new DocBlox_Transformer_Transformation($tr, 'copy', 'FileIo', '/tmp/docblox_a', 'docblox_b');
     $this->fixture->transform(new DOMDocument(), $t);
     $this->assertFileExists('/tmp/docblox_a');
     $this->assertFileExists('/tmp/docblox_b');
     unlink('/tmp/docblox_a');
     unlink('/tmp/docblox_b');
 }
Ejemplo n.º 3
0
 /**
  * Tests whether an execute call will yield the desired results.
  *
  * @return void
  */
 public function testExecute()
 {
     DocBlox_Core_Abstract::config()->transformations = array();
     $this->fixture = new DocBlox_Transformer();
     // when nothing is added; this mock should not be invoked
     $transformation = $this->getMock('DocBlox_Transformer_Transformation', array('execute'), array($this->fixture, '', 'Xsl', '', ''));
     $transformation->expects($this->never())->method('execute');
     $this->fixture->execute();
     // when we add this mock; we expect it to be invoked
     $transformation = $this->getMock('DocBlox_Transformer_Transformation', array('execute'), array($this->fixture, '', 'Xsl', '', ''));
     $transformation->expects($this->once())->method('execute');
     $this->fixture->addTransformation($transformation);
     $this->fixture->execute();
 }
Ejemplo n.º 4
0
 /**
  * Execute the task
  *
  * @return Docblox
  * @throw BuildException
  */
 public function execute()
 {
     if (!class_exists('Parser')) {
         if (!$this->getLibraryPath()) {
             throw new BuildException('No Docblox library path set');
         }
         $libraryPath = $this->filterProperties($this->getLibraryPath());
         set_include_path(get_include_path() . PATH_SEPARATOR . $libraryPath);
         require_once 'markdown.php';
         $autoloader = new StandardAutoloader();
         $autoloader->registerPrefix('Zend', "{$libraryPath}/Zend")->registerPrefix('DocBlox', "{$libraryPath}/DocBlox")->setFallbackAutoloader(true)->register();
     }
     $parser = new Parser();
     ParserAbstract::$event_dispatcher = new sfEventDispatcher();
     if ($this->getForce()) {
         $parser->setForced($this->getForce());
     }
     if ($this->getMarkers()) {
         $parser->setMarkers($this->getMarkers());
     }
     if ($this->getTitle()) {
         $parser->setTitle($this->filterProperties($this->getTitle()));
     }
     if ($this->getValidate()) {
         $parser->setValidate($this->getValidate());
     }
     $files = new Files();
     foreach ($this->getFiles() as $file) {
         $files->addFile($this->filterProperties($file));
     }
     $xml = $parser->parseFiles($files);
     $transformer = new Transformer();
     $transformer->setSource($xml);
     if ($this->getParsePrivate()) {
         $transformer->setParseprivate($this->getParsePrivate());
     }
     if ($this->getTarget()) {
         $transformer->setTarget($this->filterProperties($this->getTarget()));
     }
     if ($this->getThemesPath()) {
         $transformer->setThemesPath($this->filterProperties($this->getThemesPath()));
     } else {
         $transformer->setThemesPath(CoreAbstract::config()->paths->themes);
     }
     if ($this->getTemplates()) {
         $transformer->setTemplates($this->getTemplates());
     } else {
         $transformer->setTemplates(CoreAbstract::config()->transformations->template->name);
     }
     $transformer->execute();
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Task entry point
  * @see Task::main()
  */
 public function main()
 {
     if (empty($this->destDir)) {
         throw new BuildException("You must supply the 'destdir' attribute", $this->getLocation());
     }
     if (empty($this->filesets)) {
         throw new BuildException("You have not specified any files to include (<fileset>)", $this->getLocation());
     }
     $this->initializeDocBlox();
     $xml = $this->parseFiles();
     $this->log("Transforming...", Project::MSG_VERBOSE);
     $transformer = new DocBlox_Transformer();
     $transformer->setTemplatesPath(DocBlox_Core_Abstract::config()->paths->templates);
     $transformer->setTemplates(DocBlox_Core_Abstract::config()->transformations->template->name);
     $transformer->setSource($xml);
     $transformer->setTarget($this->destDir->getAbsolutePath());
     $transformer->execute();
 }
Ejemplo n.º 6
0
 /**
  * Task entry point
  * @see Task::main()
  */
 public function main()
 {
     if (empty($this->destDir)) {
         throw new BuildException("You must supply the 'destdir' attribute", $this->getLocation());
     }
     if (empty($this->filesets)) {
         throw new BuildException("You have not specified any files to include (<fileset>)", $this->getLocation());
     }
     $this->initializeDocBlox();
     $xml = $this->parseFiles();
     $transformer = new DocBlox_Transformer();
     $transformer->setSource($xml);
     $transformer->setTarget($this->destDir);
     $transformer->execute();
 }
Ejemplo n.º 7
0
 /**
  * Executes the transformation process.
  *
  * @throws Zend_Console_Getopt_Exception
  *
  * @return void
  */
 public function execute()
 {
     // initialize timer
     $timer = microtime(true);
     // initialize transformer
     $transformer = new DocBlox_Transformer();
     $transformer->setTarget($this->getTarget());
     $transformer->setSource($this->getSource());
     $transformer->setTemplates($this->getTemplate());
     // enable verbose mode if the flag was set
     if ($this->getVerbose()) {
         $transformer->setLogLevel(DocBlox_Core_Log::DEBUG);
     }
     if ($this->getQuiet()) {
         $transformer->setLogLevel(DocBlox_Core_Log::QUIET);
     }
     // start the transformation process
     if (!$this->getQuiet()) {
         echo 'Starting transformation of files (this could take a while depending upon the size of your project)' . PHP_EOL;
     }
     $transformer->execute();
     if (!$this->getQuiet()) {
         echo 'Finished transformation in ' . round(microtime(true) - $timer, 2) . ' seconds' . PHP_EOL;
     }
 }
Ejemplo n.º 8
0
 /**
  * Executes the transformation process.
  *
  * @throws Zend_Console_Getopt_Exception
  *
  * @return void
  */
 public function execute()
 {
     // initialize timer
     $timer = microtime(true);
     // initialize transformer
     $transformer = new DocBlox_Transformer();
     $transformer->setThemesPath(DocBlox_Core_Abstract::config()->paths->themes);
     $transformer->setTarget($this->getTarget());
     $transformer->setSource($this->getSource());
     $transformer->setTemplates($this->getTemplate());
     $transformer->setParseprivate($this->getParseprivate());
     // add links to external docs
     $external_class_documentation = DocBlox_Core_Abstract::config()->getArrayFromPath('transformer/external-class-documentation');
     $external_class_documentation = !is_numeric(current(array_keys($external_class_documentation))) ? $external_class_documentation = array($external_class_documentation) : $external_class_documentation;
     /** @var DocBlox_Core_Config $doc */
     foreach ($external_class_documentation as $doc) {
         if (empty($doc)) {
             continue;
         }
         $transformer->setExternalClassDoc((string) $doc['prefix'], (string) $doc['uri']);
     }
     // start the transformation process
     if (!$this->getQuiet()) {
         echo 'Starting transformation of files (this could take a while depending upon the size of your project)' . PHP_EOL;
     }
     $transformer->execute();
     if (!$this->getQuiet()) {
         echo 'Finished transformation in ' . round(microtime(true) - $timer, 2) . ' seconds' . PHP_EOL;
     }
 }