Author: FrankStelzer
Date: 2010-09-13 07:56:31 +0200 (Mon, 13 Sep 2010)
New Revision: 30892

Added:
   plugins/sfPHPUnit2Plugin/trunk/data/template/phpunit.xml.dist.tpl
   
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateConfigurationTask.class.php
Modified:
   plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php
   plugins/sfPHPUnit2Plugin/trunk/package.xml
Log:
[sfPHPUnit2Plugin] added task for generating the  default phpunit.xml.dist 
configuration file

Added: plugins/sfPHPUnit2Plugin/trunk/data/template/phpunit.xml.dist.tpl
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/data/template/phpunit.xml.dist.tpl           
                (rev 0)
+++ plugins/sfPHPUnit2Plugin/trunk/data/template/phpunit.xml.dist.tpl   
2010-09-13 05:56:31 UTC (rev 30892)
@@ -0,0 +1,16 @@
+<phpunit
+  colors="true"
+  convertErrorsToExceptions="true"
+  convertNoticesToExceptions="true"
+  convertWarningsToExceptions="true"
+  stopOnFailure="true">
+  
+  <testsuites>
+    <testsuite name="Unit Tests">
+      <directory>test/phpunit/unit/</directory>
+    </testsuite>
+     <testsuite name="Functional Tests">
+       <directory>test/phpunit/functional/</directory>
+    </testsuite>
+  </testsuites>
+</phpunit>
\ No newline at end of file

Modified: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php 
2010-09-12 21:35:47 UTC (rev 30891)
+++ plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php 
2010-09-13 05:56:31 UTC (rev 30892)
@@ -89,7 +89,7 @@
    *
    * @return string
    */
-  protected function getTemplate( $templateName )
+  protected function getTemplate($templateName)
   {
     // check if template does exist in custom dir
     $templatePath = $this->getProjectDataDir().'/sfPHPUnit2Plugin/template/' . 
$templateName;
@@ -118,7 +118,7 @@
    */
   protected function renderTemplate($content, array $replacePairs)
   {
-    return strtr( $content, $replacePairs );
+    return strtr($content, $replacePairs);
   }
 
   /**

Added: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateConfigurationTask.class.php
===================================================================
--- 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateConfigurationTask.class.php
                                (rev 0)
+++ 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateConfigurationTask.class.php
        2010-09-13 05:56:31 UTC (rev 30892)
@@ -0,0 +1,67 @@
+<?php
+
+/*
+ * This file is part of the sfPHPUnit2Plugin package.
+ * (c) 2010 Frank Stelzer <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Generates a PHPUnit test file for unit tests.
+ *
+ * @package    sfPHPUnit2Plugin
+ * @subpackage task
+ *
+ * @author     Frank Stelzer <[email protected]>
+ */
+class sfPHPUnitGenerateConfigurationTestTask extends sfPHPUnitGenerateBaseTask
+{
+  /**
+   * @see sfTask
+   */
+  protected function configure()
+  {
+    /*
+    $this->addArguments(array(
+    ));
+    */
+
+    $this->addOptions(array(
+      new sfCommandOption('overwrite', null, sfCommandOption::PARAMETER_NONE, 
'Forces the task to overwrite any existing configuration file'),
+    ));
+
+    $this->namespace        = 'phpunit';
+    $this->name             = 'generate-configuration';
+    $this->briefDescription = 'Generates the configuration xml for unit tests';
+    $this->detailedDescription = <<<EOF
+The [phpunit:generate-configuration|INFO] generates the default configuration 
xml for unit tests, which is lateron used by PHPUnit
+
+Call it with:
+
+  [php symfony phpunit:generate-configuration|INFO]
+EOF;
+  }
+
+   /**
+   * @see sfTask
+   */
+  protected function execute($arguments = array(), $options = array())
+  {
+    $this->createBootstrap();
+
+    $template = $this->getTemplate('phpunit.xml.dist.tpl');
+
+    $filepath = sfConfig::get('sf_root_dir').'/phpunit.xml.dist';
+    $replacePairs = array();
+
+    $rendered = $this->renderTemplate($template, $replacePairs);
+
+    if(!file_exists($filepath) || $options['overwrite'])
+    {
+      file_put_contents($filepath, $rendered);
+      $this->logSection('file+', 'phpunit.xml.dist');
+    }
+  }
+}


Property changes on: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateConfigurationTask.class.php
___________________________________________________________________
Added: svn:executable
   + *

Modified: plugins/sfPHPUnit2Plugin/trunk/package.xml
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/package.xml  2010-09-12 21:35:47 UTC (rev 
30891)
+++ plugins/sfPHPUnit2Plugin/trunk/package.xml  2010-09-13 05:56:31 UTC (rev 
30892)
@@ -112,8 +112,9 @@
                        <date>2010-06-09</date>
                        <license>MIT</license>
                        <notes>
+                               * added task for generating the default 
phpunit.xml.dist configuration file
+                               * added return value of the PHPUnit command 
line executions (thanks to Brent Shaffer)
                                * added best practise hint for 
phpunit.xml(.dist) (thanks to Christian Schaefer, 
http://test.ical.ly/2010/08/24/best-practice-how-to-ship-phpunit-configuration/ 
)
-                               * added return value of the PHPUnit command 
line executions (thanks to Brent Shaffer)
                        </notes>
                </release>
                

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to