Author: maksim_ka Date: 2010-02-03 09:42:22 +0100 (Wed, 03 Feb 2010) New Revision: 27473
Added: plugins/sfPhpunitPlugin/branches/1.2/config/app.yml plugins/sfPhpunitPlugin/branches/1.2/lib/testcase/sfBasePhpunitSeleniumTestCase.php Removed: plugins/sfPhpunitPlugin/branches/1.2/config/config.php Modified: plugins/sfPhpunitPlugin/branches/1.2/lib/test/sfPhpunitSuiteLoader.class.php Log: [sfPhpunitPlugin][sf1.2] add config. add selenium base test case. Added: plugins/sfPhpunitPlugin/branches/1.2/config/app.yml =================================================================== --- plugins/sfPhpunitPlugin/branches/1.2/config/app.yml (rev 0) +++ plugins/sfPhpunitPlugin/branches/1.2/config/app.yml 2010-02-03 08:42:22 UTC (rev 27473) @@ -0,0 +1,19 @@ +# You can find more information about this file on the symfony website: +# http://www.symfony-project.org/reference/1_4/en/07-Databases +all: + sfPhpunitPlugin: + amf: + endpoint: false + selenium: + driver: + name: false + browser: '*firefox' + browser_url: false + host: false + port: false + timeout: false + http_timeout: false + sleep: false + wait: false + + \ No newline at end of file Deleted: plugins/sfPhpunitPlugin/branches/1.2/config/config.php =================================================================== --- plugins/sfPhpunitPlugin/branches/1.2/config/config.php 2010-02-03 08:42:17 UTC (rev 27472) +++ plugins/sfPhpunitPlugin/branches/1.2/config/config.php 2010-02-03 08:42:22 UTC (rev 27473) @@ -1,3 +0,0 @@ -<?php - -sfToolkit::addIncludePath(realpath(dirname(__FILE__).'/../lib/vendor/')); \ No newline at end of file Modified: plugins/sfPhpunitPlugin/branches/1.2/lib/test/sfPhpunitSuiteLoader.class.php =================================================================== --- plugins/sfPhpunitPlugin/branches/1.2/lib/test/sfPhpunitSuiteLoader.class.php 2010-02-03 08:42:17 UTC (rev 27472) +++ plugins/sfPhpunitPlugin/branches/1.2/lib/test/sfPhpunitSuiteLoader.class.php 2010-02-03 08:42:22 UTC (rev 27473) @@ -85,11 +85,9 @@ * * @return PHPUnit_Framework_TestResult */ - public function run() + public function run($result = null) { - $this->getSuite()->run($result = new PHPUnit_Framework_TestResult()); - - return $result; + return $this->getSuite()->run($result); } /** Added: plugins/sfPhpunitPlugin/branches/1.2/lib/testcase/sfBasePhpunitSeleniumTestCase.php =================================================================== --- plugins/sfPhpunitPlugin/branches/1.2/lib/testcase/sfBasePhpunitSeleniumTestCase.php (rev 0) +++ plugins/sfPhpunitPlugin/branches/1.2/lib/testcase/sfBasePhpunitSeleniumTestCase.php 2010-02-03 08:42:22 UTC (rev 27473) @@ -0,0 +1,109 @@ +<?php + +require_once 'PHPUnit/Extensions/SeleniumTestCase.php'; + +abstract class sfBasePhpunitSeleniumTestCase + extends PHPUnit_Extensions_SeleniumTestCase + implements sfPhpunitFixtureAggregator +{ + /** + * + * @var sfPhpunitFixture + */ + protected $_fixture; + + /** + * 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! + */ + public function setUp() + { + $this->_startFillDriverWithDefaultOptions(); + $this->_start(); + } + + /** + * Please do not touch this method and use _end directly! + */ + public function tearDown() + { + $this->_end(); + } + + public function getPackageFixtureDir() + { + $reflection = new ReflectionClass($this); + $path = dirname($reflection->getFileName()); + $path = substr_replace($path, 'fixtures/', strpos($path, 'phpunit/') + 8, 0); + + return $path; + } + + public function getOwnFixtureDir() + { + $reflection = new ReflectionClass($this); + $path = str_replace('.php', '', $reflection->getFileName()); + $path = substr_replace($path, 'fixtures/', strpos($path, 'phpunit/') + 8, 0); + + return $path; + } + + public function getCommonFixtureDir() + { + return sfConfig::get('sf_test_dir').'/phpunit/fixtures/common'; + } + + public function getSymfonyFixtureDir() + { + return sfConfig::get('sf_data_dir').'/fixtures'; + } + + /** + * + * + * @return sfPhpunitFixture|mixed + */ + protected function fixture($id = null) + { + if (!$this->_fixture) $this->_initFixture(); + + return is_null($id) ? $this->_fixture : $this->_fixture->get($id); + } + + protected function _initFixture(array $options = array()) + { + $this->_fixture = sfPhpunitFixture::build($this, $options); + } + + protected function _startFillDriverWithDefaultOptions() + { + $selenium_options = sfConfig::get('app_sfPhpunitPlugin_selenium', array()); + + foreach ($selenium_options['driver'] as $option => $value) { + if (false === $value) continue; + + $setOption = explode('_', $option); + $setOption = 'set'.implode(array_map('ucfirst', $setOption)); + if (!method_exists($this->drivers[0], $setOption)) { + throw new Exception('Invalid selenium option `'.$option.'` provided. Please check the app.yml config file'); + } + + $this->drivers[0]->$setOption($value); + } + } +} \ No newline at end of file -- 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.
