TIP: Use Markdown or, <pre> for multi line code blocks / <code> for inline code.
These forums are read-only and for archival purposes only!
Please join our new forums at discourse.kohanaframework.org
Testing a module
  • I want to create a module and I want to test it. Is it possible to test it using Kohana unittest without having any application? I just want to test the module, not the whole application.

  • Yep, that works quite easily: just give your test classes a /** @group blah */ annotation in their docblocks, and run phpunit with the --group=blah parameter. See what the existing groups are with phpunit --list-groups.

    There's no need to have any application classes or anything.

  • @koes if it's about grouping tests, then @samwilson has it right.

    But reading your question again, I think you're asking if you need to have your module developed and tested independently? without a Kohana application around?

    Well, you need to have a Kohana application. You need to at least bootstrap the autoloader so that phpunit can find your classes. You also want to use Kohana unittest module, so that needs to be enabled in your modules list too. Needless to say that sometimes we use the helper classes like Date/Inflector inside our modules so we pretty much depend on the system.

    If you need to have your module folder independent, couldn't you enable your module in the Kohana app using the full path without the MODPATH constant? Or maybe you reverse folder structure and put the whole application inside the test folder of your module?

  • Yes, quite right @enov.

    I guess I was thinking 'application' meant just the application directory! A couple of the programmes I work on are contained completely in modules, you see, and the APPPATH is just for cache, logs, config, and sometimes data. :-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion