These forums are read-only and for archival purposes only!
Please join our new forums at
Promoting automate test in the framework
  • I have been working with php for more than 5 years. Lately I have worked in rubyonrails. I have done a few projects in this very nice framework. What I like best from rails and ruby: they both promote automate test and there are so many rich libs. Rspec and TestUnit are very easy to learn comparing to PhpUnit.

    I have to develop a very big project in the next coming month. I am a big fan in cakephp but I realize that cakephp will not meet my project requirement. I am a quick learner. After reading doc from Kohana official website, I will use Kohana for this project.

    After having done some search on Kohana, I still have a few topics to concern about

    • The test module is lack of doc. I am not clear how to test model, controller, functional test. Could anyone provide me ideas, tutorials, examples, resources ?

    • The application environment is not quite clear. Sorry because I am pretty family with rubyonrails . I feel like environment in rails make more sense to me. I can have one gem in a specific environment. for example I have rspec gem (for automate test ) for test environment only and I have unicorn gem for production only. For those who are new to ruby, gem is something similar to "module" in kohana. Could anyone tell me how to tell kohana to just load "unittest" in test environment only ? because I dont want to load unittest in production env.

    • In Rails there is an app console mode called rails console. with rails console we can interact with models via console mode . Is there anything similar to this in Kohana ?

      Your guidance would be highly appreciated.


  • Welcome to Kohana. I'm not familar with Ruby but to answer your second question; the modules you wish to use are setup in bootstap as an array. Therefore you can check the Kohana::$environment and setup the module array depending on what the environment you are in. For example in your bootstrap:

    if (Kohana::$environment === Kohana::DEVELOPMENT)
            'unittest' => MODPATH.'unittest', // Unit testing
  • It is a bit ugly, but make sense. Thanks you very much

  • I've found a better way to do that is to store the enabled modules in a config file and then have environment specific config files.

    I would recommend taking a look through that whole repo as there a lot of best practices and examples in there.

  • @brandons - That's a great link, thx for sharing. Do you have an example how to use the minion-task-migrations module?

  • @matino: You can run a migration task like so:

    // Up
    $migration_task = Minion_Task::factory('migrations_run')->execute(array());
    // Down 
    $migration_task = Minion_Task::factory('migrations_run')->execute(array('down' => TRUE));
  • @brandons that is a great approach.

  • @brandons, that looks like a much better way to do it. Thanks for sharing.

  • OK I tried implementing this but synapse studios are using modified core for this to work. In particular trying to create and attach a new Config to Kohana::$config before calling Kohana::init is useless because a new Config is created within the method replacing the previous one. Synapse Studios have overcome that by implementing a singleton call Kohana_Config::instance() within the Kohana::init.

    So what are the devs thoughts on this?

Howdy, Stranger!

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

In this Discussion