Author: FrankStelzer
Date: 2010-05-11 00:10:15 +0200 (Tue, 11 May 2010)
New Revision: 29407

Added:
   plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/
   plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/bootstrap.tpl
   plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/selenium_test.tpl
   
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateSeleniumTestTask.class.php
   plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitSeleniumTask.class.php
   
plugins/sfPHPUnit2Plugin/trunk/lib/test/sfPHPUnitBaseSeleniumTestCase.class.php
Modified:
   plugins/sfPHPUnit2Plugin/trunk/README
   plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitFunctionalTask.class.php
   plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php
   
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateFunctionalTestTask.class.php
   plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitUnitTask.class.php
   plugins/sfPHPUnit2Plugin/trunk/package.xml
Log:
[sfPHPUnit2Plugin] added selenium support, some other improvements, prepared 
0.9 version

Modified: plugins/sfPHPUnit2Plugin/trunk/README
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/README       2010-05-10 21:26:53 UTC (rev 
29406)
+++ plugins/sfPHPUnit2Plugin/trunk/README       2010-05-10 22:10:15 UTC (rev 
29407)
@@ -5,11 +5,15 @@
 Symfony 1.x provides lime as default testing framework, but this does not 
match to every company's testing guidelines.
 This plugin provides several tasks for generating PHPUnit test cases and for 
executing them. It mimics the lime
 usage, so that switching from lime tests is quite easy.
+This plugin is optimized for sf 1.4 projects, but with some tricks it works 
also for sf 1.2.
 
+The new plugin version supports generation and execution of selenium tests. 
Those tests are somehow an extension of functional tests but are handled 
independant from existing unit or functional tests. Developers who only want to 
run the normal native functional tests do not have to worry about the selenium 
handling.
+
 ## Requirements ##
   * a symfony version greater equal 1.2 is required
+  * a special compatibility task has to be run for sf 1.2 projects (see 
phpunit:generate-compat below)
   * the PHPUnit command-line test runner has to be available as `phpunit` in 
the command line (PHPUnit is **not** bundled with this plugin)
-  * for running *all* tests PHPUnit 3.4 is required, otherwise this plugin is 
independant to the PHPUnit version
+  * PHPUnit 3.4 is required for running *all* tests, otherwise this plugin is 
independant to the PHPUnit version
 
 ## Installation ##
 This plugin is marked as **beta** currently. Therefore the stability option 
has to be added to the plugin installer
@@ -38,6 +42,14 @@
 Creates a new file in 
*test/phpunit/functional/<application>/<controller_name>ActionsTest.php*.
 This generation is not done automatically when a new module is generated and 
has to be called by hand currently.
 
+### Selenium tests ###
+Generating a test case for a selenium test:
+
+        $ ./symfony phpunit:generate-selenium <application> <controller_name>
+
+Creates a new file in 
*test/phpunit/selenium/&lt;application&gt;/&lt;controller_name&gt;ActionsTest.php*.
+This generation is not done automatically when a new module is generated and 
has to be called by hand currently.
+
 ### Options ###
   * **overwrite**: An existing test case is not overwritten by default. 
Overwritting is enabled with this option.
   * **dir** (unit test only): A subfolder the generated test case should be 
saved in.
@@ -50,6 +62,9 @@
         $ #test/phpunit/functional/frontend/homeActionsTest.php
         $ ./symfony phpunit:generate-functional frontend home
 
+        $ #test/phpunit/selenium/frontend/homeActionsTest.php
+        $ ./symfony phpunit:generate-selenium frontend home
+
 ## Usage ##
 ### Unit tests ###
 The unit test given in the [official 
documenation](http://www.symfony-project.org/book/1_2/15-Unit-and-Functional-Testing#chapter_15_unit_tests
 "Unit and Functional Testing") would look like this:
@@ -135,6 +150,11 @@
 This could be realized, because the browser instance is linked here to the 
current PHPUnit test case and not to the lime test instance.
 Only the way the browser instance has to be fetched is different.
 
+### Selenium tests ###
+Selenium tests behave like functional tests with additional Selenium support. 
The according base class for Selenium tests extends 
**PHPUnit_Extensions_SeleniumTestCase** of PHPUnit.
+Please refer to the official documentation of 
[PHPUnit](http://www.phpunit.de/manual/current/en/selenium.html) and 
[Selenium](http://seleniumhq.org/docs/) for detailed information and usage.
+
+
 ## Execute test cases ##
 ### Unit tests ###
 Executing a unit test:
@@ -154,9 +174,20 @@
 
 Both parameters are optional. When they are not given, all functional tests 
will be executed.
 
+### Selenium tests ###
+Executing a selenium test:
+
+        $ ./symfony phpunit:test-selenium <application> <controller_name>
+        $ # equal to
+        $ phpunit 
test/phpunit/selenium/<application>/<controller_name>ActionsTest.php
+
+Both parameters are optional. When they are not given, all selenium tests will 
be executed.
+
+
 ### Options ###
   * **options**: An option string which is directly passed to the command-line 
test runner of PHPUnit.
   * **dir** (unit test only): The subfolder an existing unit test is located 
in.
+  * **base** (experimental): The base folder path where custom test cases are 
located in. Could be used for plugin tests for example.
 
 ### Examples ###
 Executing a unit test:
@@ -187,13 +218,19 @@
 
         $ ./symfony phpunit:test-all --options="--colors --process-isolation"
 
+Executing a unit test within a plugin:
+
+        $ # file has to be located in 
plugins/sfPHPUnit2Plugin/test/unit/fooPluginTest.php
+        $ ./symfony phpunit:test-unit --base="plugins/sfPHPUnit2Plugin/test" 
fooPlugin
+
+
 ## Some Hints ##
   * **Functional tests of several applications have to be run with the 
"process isolation" PHPUnit option (only available in PHPUnit 3.4)!**
   * Use the *colors* option of PHPUnit to get a colorful representation of 
your test results
   * You do not like the PHPUnit syntax? Use **$this->getTest()** to retrieve a 
instance of sfPHPUnitTest, which mimics the lime-like interface!
   * Use the **_start** and **_end** methods for doing something just before 
and after a test (please do not overwrite the setUp and tearDown methods)!
   * implement the **getApplication** method in your unit test and call 
**getContext** afterwards for creating an according sfContext instance
-  * add a 
***[phpunit.xml](http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html)***
 in the project's root dir for defining default configuration options for 
PHPUnit calls  
+  * add a 
***[phpunit.xml](http://www.phpunit.de/manual/3.4/en/appendixes.configuration.html)***
 in the project's root dir for defining default configuration options for 
PHPUnit calls
 
         <phpunit
           colors="true"
@@ -202,17 +239,27 @@
           convertWarningsToExceptions="true"
           stopOnFailure="true">
         </phpunit>
-      
 
+
 ## Snippets ##
 Loading fixtures in your test:
 
+Doctrine:
       protected function _start()
       {
         new 
sfDatabaseManager(ProjectConfiguration::getApplicationConfiguration('frontend', 
'test', true));
-        Doctrine_Core::loadData(sfConfig::get('sf_data_dir').'/fixtures');
+        Doctrine_Core::loadData(sfConfig::get('sf_test_dir').'/fixtures');
       }
 
+Propel:
+      protected function _start()
+      {
+        new 
sfDatabaseManager(ProjectConfiguration::getApplicationConfiguration('frontend', 
'test', true));
+        $loader = new sfPropelData();
+        $loader->loadData(sfConfig::get('sf_test_dir').'/fixtures');
+      }
+
+
 Creating a sfContext instance in a unit test:
 
       protected function getApplication()
@@ -223,4 +270,17 @@
       public function testContext()
       {
         $this->assertEquals('frontend', 
$this->getContext()->getConfiguration()->getApplication());
-      }
\ No newline at end of file
+      }
+
+Content of a plugin test file:
+
+      require_once 
dirname(__FILE__).'/../../../../test/phpunit/bootstrap/unit.php';
+
+      class unit_plugin_sfPHPUnit2Plugin_fooPluginTest extends 
sfPHPUnitBaseTestCase
+      {
+        public function testDefault()
+        {
+          $t = $this->getTest();
+          // test something
+        }
+      }

Added: plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/bootstrap.tpl
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/bootstrap.tpl         
                (rev 0)
+++ plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/bootstrap.tpl 
2010-05-10 22:10:15 UTC (rev 29407)
@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * This file is part of the sfPHPUnit2Plugin package.
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * Idea taken from bootstrap/functional.php of the lime bootstrap file
+ */
+
+require_once 
dirname(__FILE__).'/../../../config/ProjectConfiguration.class.php';
+require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
+
+// autoloading does not exist at this point yet, require base classes by hand
+$_phpunitPluginDir = dirname(__FILE__).'/../../../plugins/sfPHPUnit2Plugin';
+require_once $_phpunitPluginDir.'/lib/test/sfPHPUnitBaseTestCase.class.php';
+require_once 
$_phpunitPluginDir.'/lib/test/sfPHPUnitBaseSeleniumTestCase.class.php';
+
+// remove all cache
+sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));

Added: plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/selenium_test.tpl
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/selenium_test.tpl     
                        (rev 0)
+++ plugins/sfPHPUnit2Plugin/trunk/data/template/selenium/selenium_test.tpl     
2010-05-10 22:10:15 UTC (rev 29407)
@@ -0,0 +1,17 @@
+<?php
+require_once dirname(__FILE__).'/../../bootstrap/selenium.php';
+
+class selenium_{controller_class}ActionsTest extends 
sfPHPUnitBaseSeleniumTestCase
+{
+  protected function setUp()
+  {
+    // $this->setBrowser('*firefox');
+    // $this->setBrowserUrl('http://localhost/{controller_name}/');
+  }
+
+  public function testTitle()
+  {
+    // $this->open('http://localhost/{controller_name}/');
+    // $this->assertTitle('Example WWW Page');
+  }
+}
\ No newline at end of file

Modified: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitFunctionalTask.class.php
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitFunctionalTask.class.php   
2010-05-10 21:26:53 UTC (rev 29406)
+++ plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitFunctionalTask.class.php   
2010-05-10 22:10:15 UTC (rev 29407)
@@ -30,6 +30,7 @@
 
     $this->addOptions(array(
     new sfCommandOption('options', null, sfCommandOption::PARAMETER_REQUIRED, 
'Options for PHPUnit which are directly passed to the test runner'),
+    new sfCommandOption('base', null, sfCommandOption::PARAMETER_REQUIRED, 
'The base folder path where custom test cases are located in'),
     ));
 
     $this->namespace        = 'phpunit';
@@ -48,6 +49,11 @@
    */
   protected function getRelativePath($arguments = array(), $options = array())
   {
+    if ($options['base'])
+    {
+      return $options['base'].'/functional'.($arguments['application']? 
'/'.$arguments['application'] : '');
+    }
+
     return 'test/phpunit/functional'.($arguments['application']? 
'/'.$arguments['application'] : '');
   }
 

Modified: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php 
2010-05-10 21:26:53 UTC (rev 29406)
+++ plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateBaseTask.class.php 
2010-05-10 22:10:15 UTC (rev 29407)
@@ -61,12 +61,22 @@
     // does bootstrap dir already exists?
     if (!file_exists($bootstrapDir))
     {
-      // create bootstrap dir and copy bootstrap files there
+      // create bootstrap dir
+      $this->logSection('dir+', $bootstrapDir);
       mkdir($bootstrapDir, 0755, true);
-      copy($templateDir.'/unit/bootstrap.tpl', $bootstrapDir.'/unit.php');
-      copy($templateDir.'/functional/bootstrap.tpl', 
$bootstrapDir.'/functional.php');
     }
 
+    // copy bootstrap files
+    $bootstrapFiles = array('/unit/bootstrap.tpl' => '/unit.php', 
'/functional/bootstrap.tpl' => '/functional.php', '/selenium/bootstrap.tpl' => 
'/selenium.php');
+    foreach ($bootstrapFiles as $source => $target)
+    {
+      if (!file_exists($bootstrapDir.$target))
+      {
+        $this->logSection('file+', $bootstrapDir.$target);
+        copy($templateDir.$source, $bootstrapDir.$target);
+      }
+    }
+
     return true;
   }
 

Modified: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateFunctionalTestTask.class.php
===================================================================
--- 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateFunctionalTestTask.class.php
       2010-05-10 21:26:53 UTC (rev 29406)
+++ 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateFunctionalTestTask.class.php
       2010-05-10 22:10:15 UTC (rev 29407)
@@ -25,7 +25,7 @@
   {
     $this->addArguments(array(
     new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The 
application of the controller to test'),
-    new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The controller 
name to test'),
+    new sfCommandArgument('controller', sfCommandArgument::REQUIRED, 'The 
controller name to test'),
     ));
 
     $this->addOptions(array(
@@ -54,16 +54,16 @@
 
     $template = $this->getTemplate('functional/functional_test.tpl');
 
-    $filename = $arguments['name'] . 'ActionsTest.php';
+    $filename = $arguments['controller'] . 'ActionsTest.php';
     $replacePairs = array(
-    '{controller_class}' => $arguments['application'] . '_' . 
$arguments['name'],
-    '{controller_name}' => $arguments['name'],
+    '{controller_class}' => $arguments['application'] . '_' . 
$arguments['controller'],
+    '{controller_name}' => $arguments['controller'],
     '{application}' => $arguments['application']
     );
 
     $rendered = $this->renderTemplate($template, $replacePairs);
     $this->saveFile($rendered, 
'functional/'.$arguments['application'].'/'.$filename, $options);
 
-    $this->logSection('help', 'run this test with: ./symfony 
phpunit:test-functional '.$arguments['application'].' '.$arguments['name']);
+    $this->logSection('help', 'run this test with: ./symfony 
phpunit:test-functional '.$arguments['application'].' 
'.$arguments['controller']);
   }
 }

Added: 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateSeleniumTestTask.class.php
===================================================================
--- 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateSeleniumTestTask.class.php
                         (rev 0)
+++ 
plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitGenerateSeleniumTestTask.class.php
 2010-05-10 22:10:15 UTC (rev 29407)
@@ -0,0 +1,71 @@
+<?php
+
+/*
+ * This file is part of the sfPHPUnit2Plugin package.
+ * (c) 2010 Frank Stelzer <[email protected]>
+ * (c) 2010 Richard Shank <[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 Selenium tests.
+ *
+ * @package    sfPHPUnit2Plugin
+ * @subpackage task
+ *
+ * @author     Frank Stelzer <[email protected]>
+ * @author     Richard Shank <[email protected]>
+ */
+class sfPHPUnitGenerateSeleniumTestTask extends sfPHPUnitGenerateBaseTask
+{
+  /**
+   * @see sfTask
+   */
+  protected function configure()
+  {
+    $this->addArguments(array(
+    new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The 
application of the controller to test'),
+    new sfCommandArgument('controller', sfCommandArgument::REQUIRED, 'The 
controller name to test'),
+    ));
+
+    $this->addOptions(array(
+    new sfCommandOption('overwrite', null, sfCommandOption::PARAMETER_NONE, 
'Forces the task to overwrite any existing files'),
+    ));
+
+    $this->namespace        = 'phpunit';
+    $this->name             = 'generate-selenium';
+    $this->briefDescription = 'Generates a test case for Selenium tests';
+    $this->detailedDescription = <<<EOF
+The [phpunit:generate-selenium|INFO] generates a test case for Selenium tests, 
which is lateron
+executable with PHPUnit.
+
+Call it with:
+
+  [php symfony phpunit:generate-selenium|INFO]
+EOF;
+  }
+
+  /**
+   * @see sfTask
+   */
+  protected function execute($arguments = array(), $options = array())
+  {
+    $this->createBootstrap();
+
+    $template = $this->getTemplate('selenium/selenium_test.tpl');
+
+    $filename = $arguments['controller'] . 'ActionsTest.php';
+    $replacePairs = array(
+    '{controller_class}' => $arguments['application'] . '_' . 
$arguments['controller'],
+    '{controller_name}' => $arguments['controller'],
+    '{application}' => $arguments['application']
+    );
+
+    $rendered = $this->renderTemplate($template, $replacePairs);
+    $this->saveFile($rendered, 
'selenium/'.$arguments['application'].'/'.$filename, $options);
+
+    $this->logSection('help', 'run this test with: ./symfony 
phpunit:test-selenium '.$arguments['application'].' '.$arguments['controller']);
+  }
+}

Added: plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitSeleniumTask.class.php
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitSeleniumTask.class.php     
                        (rev 0)
+++ plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitSeleniumTask.class.php     
2010-05-10 22:10:15 UTC (rev 29407)
@@ -0,0 +1,77 @@
+<?php
+
+/*
+ * This file is part of the sfPHPUnit2Plugin package.
+ * (c) 2010 Frank Stelzer <[email protected]>
+ * (c) 2010 Richard Shank <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Launches PHPUnit Selenium tests.
+ *
+ * @package    sfPHPUnit2Plugin
+ * @subpackage task
+ *
+ * @author     Frank Stelzer <[email protected]>
+ * @author     Richard Shank <[email protected]>
+ */
+class sfPHPUnitSeleniumTask extends sfPHPUnitBaseTask
+{
+  /**
+   * @see sfTask
+   */
+  protected function configure()
+  {
+    $this->addArguments(array(
+    new sfCommandArgument('application', sfCommandArgument::OPTIONAL, 'The 
application of the controller to test'),
+    new sfCommandArgument('name', sfCommandArgument::OPTIONAL, 'The controller 
name to test')
+    ));
+
+    $this->addOptions(array(
+    new sfCommandOption('options', null, sfCommandOption::PARAMETER_REQUIRED, 
'Options for PHPUnit which are directly passed to the test runner'),
+    new sfCommandOption('base', null, sfCommandOption::PARAMETER_REQUIRED, 
'The base folder path where custom test cases are located in'),
+    ));
+
+    $this->namespace        = 'phpunit';
+    $this->name             = 'test-selenium';
+    $this->briefDescription = 'Launches selenium tests';
+    $this->detailedDescription = <<<EOF
+The [phpunit:test-selenium|INFO] launches selenium tests.
+Call it with:
+
+  [php symfony phpunit:test-selenium|INFO]
+EOF;
+  }
+
+  /**
+   * @see sfPHPUnitBaseTask
+   */
+  protected function getRelativePath($arguments = array(), $options = array())
+  {
+    if ($options['base'])
+    {
+      return $options['base'].'/selenium'.($arguments['application']? 
'/'.$arguments['application'] : '');
+    }
+
+    return 'test/phpunit/selenium'.($arguments['application']? 
'/'.$arguments['application'] : '');
+  }
+
+  /**
+   * @see sfPHPUnitBaseTask
+   */
+  protected function getFileSuffix()
+  {
+    return 'ActionsTest';
+  }
+
+  /**
+   * @see sfPHPUnitBaseTask
+   */
+  protected function getFileSuffixWithExtension()
+  {
+    return 'ActionsTest.php';
+  }
+}

Modified: plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitUnitTask.class.php
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitUnitTask.class.php 
2010-05-10 21:26:53 UTC (rev 29406)
+++ plugins/sfPHPUnit2Plugin/trunk/lib/task/sfPHPUnitUnitTask.class.php 
2010-05-10 22:10:15 UTC (rev 29407)
@@ -30,6 +30,7 @@
     $this->addOptions(array(
     new sfCommandOption('options', null, sfCommandOption::PARAMETER_REQUIRED, 
'Options for PHPUnit which are directly passed to the test runner'),
     new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED, 'The 
subfolder the test case is located in'),
+    new sfCommandOption('base', null, sfCommandOption::PARAMETER_REQUIRED, 
'The base folder path where custom test cases are located in'),
     ));
 
     $this->namespace        = 'phpunit';
@@ -48,6 +49,11 @@
    */
   protected function getRelativePath($arguments = array(), $options = array())
   {
+    if ($options['base'])
+    {
+      return $options['base'].'/unit'.($options['dir']? '/'.$options['dir'] : 
'');
+    }
+
     return 'test/phpunit/unit'.($options['dir']? '/'.$options['dir'] : '');
   }
 

Added: 
plugins/sfPHPUnit2Plugin/trunk/lib/test/sfPHPUnitBaseSeleniumTestCase.class.php
===================================================================
--- 
plugins/sfPHPUnit2Plugin/trunk/lib/test/sfPHPUnitBaseSeleniumTestCase.class.php 
                            (rev 0)
+++ 
plugins/sfPHPUnit2Plugin/trunk/lib/test/sfPHPUnitBaseSeleniumTestCase.class.php 
    2010-05-10 22:10:15 UTC (rev 29407)
@@ -0,0 +1,126 @@
+<?php
+
+/*
+ * This file is part of the sfPHPUnit2Plugin package.
+ * (c) 2010 Frank Stelzer <[email protected]>
+ * (c) 2010 Richard Shank <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * sfBasePHPUnitBaseSeleniumTestCase is the super class for all Selenium
+ * tests using PHPUnit.
+ *
+ * @package    sfPHPUnit2Plugin
+ * @subpackage test
+ * @author     Frank Stelzer <[email protected]>
+ * @author     Richard Shank <[email protected]>
+ */
+abstract class sfPHPUnitBaseSeleniumTestCase extends 
PHPUnit_Extensions_SeleniumTestCase
+{
+  /**
+   * The sfPHPUnitTest instance for lime compatibility
+   *
+   * @var sfPHPUnitTest
+   */
+  private $test = null;
+
+  /**
+   * The sfContext instance
+   *
+   * @var sfContext
+   */
+  private $context = null;
+
+  /**
+   * Dev hook for custom "setUp" stuff
+   * Overwrite it in your test class, if you have to execute stuff before a 
test is called.
+   */
+  protected function _start()
+  {
+  }
+
+  /**
+   * Dev hook for custom "tearDown" stuff
+   * Overwrite it in your test class, if you have to execute stuff after a 
test is called.
+   */
+  protected function _end()
+  {
+  }
+
+  /**
+   * Please do not touch this method and use _start directly!
+   */
+  protected function setUp()
+  {
+    $this->_start();
+  }
+
+  /**
+   * Please do not touch this method and use _end directly!
+   */
+  protected function tearDown()
+  {
+    $this->_end();
+  }
+
+  /**
+   * A unit test does not have loaded the whole symfony context on start-up, 
but
+   * you can create a working instance if you need it with this method
+   * (taken from the bootstrap file).
+   *
+   * @return sfContext
+   */
+  protected function getContext()
+  {
+    if (!$this->context)
+    {
+      // ProjectConfiguration is already required in the bootstrap file
+      $configuration = 
ProjectConfiguration::getApplicationConfiguration($this->getApplication(), 
$this->getEnvironment(), true);
+      $this->context = sfContext::createInstance($configuration);
+    }
+
+    return $this->context;
+  }
+
+  /**
+   * Returns current sfPHPUnitTest
+   *
+   * @return sfPHPUnitTest
+   */
+  protected function getTest()
+  {
+    if (!$this->test)
+    {
+      $this->test = new sfPHPUnitTest( $this );
+    }
+
+    return $this->test;
+  }
+
+  /**
+   * Returns application name
+   *
+   * Overwrite this method if you need a context instance in your unit test!
+   *
+   * @return string
+   */
+  protected function getApplication()
+  {
+    throw new Exception( 'Application name is not defined. Overwrite 
"getApplication" in your unit test!');
+  }
+
+  /**
+   * Returns environment name
+   *
+   * Overwrite this method if you need a context instance in your unit test!
+   *
+   * @return string test by default
+   */
+  protected function getEnvironment()
+  {
+    return 'test';
+  }
+}
\ No newline at end of file

Modified: plugins/sfPHPUnit2Plugin/trunk/package.xml
===================================================================
--- plugins/sfPHPUnit2Plugin/trunk/package.xml  2010-05-10 21:26:53 UTC (rev 
29406)
+++ plugins/sfPHPUnit2Plugin/trunk/package.xml  2010-05-10 22:10:15 UTC (rev 
29407)
@@ -13,12 +13,12 @@
                <email>[email protected]</email>
                <active>yes</active>
        </lead>
-       <date>2010-03-01</date>
+       <date>2010-05-13</date>
        <time>10:00:00</time>
 
        <version>
-               <release>0.8.3</release>
-               <api>0.8.3</api>
+               <release>0.9</release>
+               <api>0.9</api>
        </version>
 
        <stability>
@@ -40,6 +40,10 @@
                                                <file role="data" 
name="bootstrap.tpl" />
                                                <file role="data" 
name="functional_test.tpl" />
                                        </dir>
+                                       <dir name="selenium">
+                                               <file role="data" 
name="bootstrap.tpl" />
+                                               <file role="data" 
name="selenium_test.tpl" />
+                                       </dir>
                                        <dir name="unit">
                                                <file role="data" 
name="bootstrap.tpl" />
                                                <file role="data" 
name="bootstrap_compat.tpl" />
@@ -57,12 +61,15 @@
                                        <file role="data" 
name="sfPHPUnitGenerateBaseTask.class.php" />
                                        <file role="data" 
name="sfPHPUnitGenerateCompatTask.class.php" />
                                        <file role="data" 
name="sfPHPUnitGenerateFunctionalTestTask.class.php" />
+                                       <file role="data" 
name="sfPHPUnitGenerateSeleniumTestTask.class.php" />
                                        <file role="data" 
name="sfPHPUnitGenerateUnitTestTask.class.php" />
+                                       <file role="data" 
name="sfPHPUnitSeleniumTask.class.php" />
                                        <file role="data" 
name="sfPHPUnitTestAllTask.class.php" />
                                        <file role="data" 
name="sfPHPUnitUnitTask.class.php" />
                                </dir>
                                <dir name="test">
                                        <file role="data" 
name="sfPHPUnitBaseFunctionalTestCase.class.php" />
+                                       <file role="data" 
name="sfPHPUnitBaseSeleniumTestCase.class.php" />
                                        <file role="data" 
name="sfPHPUnitBaseTestCase.class.php" />
                                        <file role="data" 
name="sfPHPUnitTest.class.php" />
                                </dir>
@@ -94,18 +101,21 @@
 
                <release>
                        <version>
-                               <release>0.8.3</release>
-                               <api>0.8.3</api>
+                               <release>0.9</release>
+                               <api>0.9</api>
                        </version>
                        <stability>
                                <release>beta</release>
                                <api>beta</api>
                        </stability>
                        <license 
uri="http://www.symfony-project.com/license";>MIT license</license>
-                       <date>2010-03-01</date>
+                       <date>2010-05-13</date>
                        <license>MIT</license>
                        <notes>
                                * added compatibility task for symfony 1.2
+                               * added selenium support (Special Thanks to 
Richard Shank!)
+        * added experimental support for plugin tests
+        * added possibility to customize skeleton template files
                        </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