Hi Simon,

you have a couple of mistakes in your code. You're extending the base class for all agavi unit tests AgaviPhpUnitTestCase. You should extend a more specialized class. Testing a BaseAction is a bit a difficult thing though: It's not a real ActionTest as the BaseAction probably cannot be run standalone like any other action could. However, a basic AgaviUnitTestcase is more geared towards testing models and self- contained classes and does not provide the required methods to properly set up an action. The best way would probably be to use the AgaviActionTestcase and the low-level methods it provides to create the action instance and then test all methods you want to but not call AgaviActionTestCase::runAction().

On a side-note: The placement for the class is just fine, you might have to add it to the autoload.xml so that the autoloader can find it.

cheers

felix


On May 27, 2009, at 8:24 AM, Simon Cornelius P Umacob wrote:

Hello,

What's the general way of writing unit tests in Agavi?  I want to get
into the habit of writing tests while writing my code.

I've examined the "test" folder in the Agavi source, but whenever I
instantiate a class, I get a "class not found" error.  How can I
automagically include my classes?

Currently, I'm doing this in order to include the classes:

$app_dir = AgaviConfig::get('core.app_dir');
require_once "$app_dir/modules/FooBar/lib/action/ FooBarBaseAction.class.php";

class FooBarBaseActionTest extends AgaviPhpUnitTestCase
{
      public function testDoSomething()
      {
          $blah = new FooBarBaseAction();
          // assert something something
      }
}

Is this the correct way of doing it?  I have this feeling that it's
not... my code looks like a temporary hack... =)

Thanks!


[ simon.cpu ]

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users


--
Felix Gilcher

Bitextender GmbH
Paul-Heyse-Str. 6
D-80336 München

T: +49 89 57 08 15 16
F: +49 89 57 08 15 17
M: +49 172 840 88 28

[email protected]
http://bitextender.com/

Amtsgericht München, HRB 174280
Geschäftsführer: David Zülke, Florian Clever

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to