Hi,
I currently work on some extension of the sfPhpunitPlugin.
Integrating PHPUnit into unit tests is quite easy, but not in
functional tests. lime_test is too much coupled in core classes there.
My proposel is to introduce a new child class of lime_test which
implements a testing adapter interface (so lime_test has not to be
touched).
The mentioned interface declares all public methods of the lime_test
class. The new child class has nothing more to do than subclassing
lime_test, because everything is already implemented in the parent
class.
With this interface i could write my own PHPUnit adapter and integrate
it in functional tests without the need writing hacks, which i
currently have to (i have to subclass lime_test for not breaking the
constuctor of sfFunctionalTest... quite ugly).
I didn't write a patch for all those needed changes, but i wrote down
some snippets (see attachment) and i hope you get my idea.
In my setup method of a PHPUnit test i could write then:
---
public function setup()
{
// this constructor would not work currently, when sfPhpunitTest
would not subclass lime_test
$this->testBrowser = new sfFunctionalTest(new sfBrowser(), new
sfPhpunitTest());
}
---
I would be very happy, if this could be integrated in the core!
Cheers,
Frank
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony developers" 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-devs?hl=en
-~----------~----~----~----~------~----~------~--~---
<?php
/**
* The constructor of sfTestFunctional and sfTestFunctionalBase
* has to be changed (lime_test has to be removed there).
*
*/
class sfTestFunctional extends sfTestFunctionalBase
{
/**
* Initializes the browser tester instance.
*
* @param sfBrowserBase $browser A sfBrowserBase instance
* @param sfTestAdapter $testAdapter A sfTestAdapter instance
*/
public function __construct(sfBrowserBase $browser, sfTestAdapter $testAdapter = null, $testers = array())
{
$testers = array_merge(array(
'view_cache' => 'sfTesterViewCache',
'form' => 'sfTesterForm',
), $testers);
parent::__construct($browser, $testAdapter, $testers);
}
}
abstract class sfTestFunctionalBase
{
/**
* Initializes the browser tester instance.
*
* @param sfBrowserBase $browser A sfBrowserBase instance
* @param lime_test $testAdapter A sfTestAdapter instance, when none is given a new lime_test instance will be created
*/
public function __construct(sfBrowserBase $browser, sfTestAdapter $testAdapter = null, $testers = array())
{
$this->browser = $browser;
if (is_null(self::$test))
{
self::$test = !is_null($testAdapter) ? $testAdapter : new lime_test(null, new lime_output_color());
}
//...
}
}
// ------------------------------------------------------------------
/**
* Custom child class for lime_test, so lime_test has not to be touched.
* Integrated in sf core.
*
*/
class sfLimeTest extends lime_test implements sfTestAdapter
{
// nothing has to be done here, because everything is already
// implemented in lime_test
}
/**
* Test adapter for PHPUnit. Integrated in a plugin.
*
*/
class sfPhpunitTest implements sfTestAdapter
{
/**
* Example testing method of needed sfTestAdapter method
*
*/
public function ok($exp, $message = '')
{
$this->testCase->assertTrue($exp, $message);
}
}
// ------------------------------------------------------------------
/**
* Interface for all public methods of lime_test
*
*/
interface sfTestAdapter
{
public function ok($exp, $message = '');
public function is($exp1, $exp2, $message = '');
public function isnt($exp1, $exp2, $message = '');
public function like($exp, $regex, $message = '');
public function unlike($exp, $regex, $message = '');
public function cmp_ok($exp1, $op, $exp2, $message = '');
public function can_ok($object, $methods, $message = '');
public function isa_ok($var, $class, $message = '');
public function is_deeply($exp1, $exp2, $message = '');
public function pass($message = '');
public function fail($message = '');
public function diag($message);
public function skip($message = '', $nb_tests = 1);
public function todo($message = '');
public function include_ok($file, $message = '');
public function comment($message);
public function info($message);
public function error($message);
//ouch
public static function get_temp_directory();
}