Jump to content

Testing module update


skorupa

Recommended Posts

Hi,

I am writing next version of my module, and want to do some update in database.

 

My plugin is published in Addons so it will get the benefit of autoupdating.

 

I found this article: http://doc.prestashop.com/display/PS15/Auto-updating+modules

but my problem now is: How To Test It.

 

Very simple thing, yet I can't find any info how to do it. If any one found solution to this problem or have some good tips how to do it I would appreciate very much.

Link to comment
Share on other sites

  • 4 weeks later...
  • 1 year later...

What I do is to call all upgrade scripts from the module install method. So I can test the full upgrade process when I do a normal installation. I'm not sure if this is the oficial way, but it seems to work.

 

public function install() {
   if (!parent::install())
      return false;

   // In this exemple 1.1.2 is the current version of the module 
   // and the others are previous versions.
   $versions =  array('1.0.0', '1.1.0', '1.1.2');
   foreach ($versions as $ver) {
      include(dirname(__FILE__).'/upgrade/install-'.$ver.'.php');
      $upgrade_func = 'upgrade_module_'.str_replace('.', '_', $ver);
      if (!$upgrade_func($this)) return false;
   }

   return true;
}
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...