diff --git a/library/Class/Cosmogramme/Integration/PhaseReviews.php b/library/Class/Cosmogramme/Integration/PhaseReviews.php
index 415c5870af41f707ac6a250e3561e3faeee849c2..0492474e46662dceb6f5928e19f1eea3a112affd 100644
--- a/library/Class/Cosmogramme/Integration/PhaseReviews.php
+++ b/library/Class/Cosmogramme/Integration/PhaseReviews.php
@@ -18,7 +18,6 @@
  * along with BOKEH; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
  */
-require_once('cosmogramme/php/classes/classe_notice_integration.php');
 
 class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integration_PhaseAbstract {
   const MY_ID=7.5;
@@ -49,21 +48,20 @@ class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integ
     return $this;
   }
 
-  public function _execute() {
 
+  public function _execute() {
     $page = 1;
     while ($records = Class_AvisNotice::findAllBy(['order' => 'id',
                                                    'limitPage' => [$page, 500]])) {
 
       if ($this->_log && (0 == ($this->_getData('nombre') % 100)))
-        $this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' records updated </span>');
+        $this->_log->ecrire('<span class="vert"> ' . $this->_getData('nombre') . ' avis mis à jour </span>');
 
       $this->runUpdateForRecords($records);
 
       $this->_resetDbConnection();
 
       $page++;
-
     }
 
     if ($this->_log) {
@@ -80,6 +78,8 @@ class Class_Cosmogramme_Integration_PhaseReviews extends Class_Cosmogramme_Integ
     }
 
   }
+
+
   protected function runUpdateForRecords($records) {
     foreach ($records as $record) {
       if ($this->isTimeOut())
diff --git a/library/Class/Migration/Patchs.php b/library/Class/Migration/Patchs.php
index ccf4eb1033e1f5a0cf1c76e24862efc053c6d7ab..5bd2b688801f134246a8b68a43ee30b7292209c4 100644
--- a/library/Class/Migration/Patchs.php
+++ b/library/Class/Migration/Patchs.php
@@ -23,7 +23,9 @@
 class Class_Migration_Patchs {
   use Trait_StaticFileSystem;
 
-  public $force = false;
+  public
+    $_last_patch_number,
+    $force = false;
 
 
   public function extensionForFile($file) {
@@ -42,7 +44,16 @@ class Class_Migration_Patchs {
   }
 
 
+  public function setLastPatchNumber($number) {
+    $this->_last_patch_number = $number;
+    return $this;
+  }
+
+
   public function getLastPatchNumber() {
+    if (isset($this->_last_patch_number))
+      return $this->_last_patch_number;
+
     $ids=[];
     foreach (self::getFileSystem()->glob(PATCH_PATH."patch_*") as $filename) {
       $ids[]=$this->versionForFile($filename);
@@ -50,14 +61,15 @@ class Class_Migration_Patchs {
     if (empty($ids))
       return 0;
     rsort($ids);
-    return $ids[0];
+    return $this->_last_patch_number = (int)$ids[0];
   }
 
 
   public function getMatchingPatchFiles($patch_level) {
+    $to_patch_level = $this->getLastPatchNumber();
     return $this->getPatchesFilteredBy(
-                                       function($version) use ($patch_level) {
-                                         return $version > (int)$patch_level;
+                                       function($version) use ($patch_level, $to_patch_level) {
+                                         return ($version > (int)$patch_level) && ($version <= $to_patch_level);
                                        });
   }
 
@@ -80,7 +92,7 @@ class Class_Migration_Patchs {
     $basePath = dirname(realpath(__FILE__));
 
     $patch_level = Class_CosmoVar::find("patch_level");
-    $visitor->visitHeader($patch_level,$this->getLastPatchNumber());
+    $visitor->visitHeader($patch_level, $this->getLastPatchNumber());
 
     $ok = true;
     foreach($this->getMatchingPatchFiles($patch_level->getValeur()) as $script) {
diff --git a/library/Class/Migration/ScriptPatchs.php b/library/Class/Migration/ScriptPatchs.php
index 336bd83741c021a5629b0a992adfa12169e801cb..bd2ddb1bfb2bb3b6bc85cab535f3fd8f413af9e6 100644
--- a/library/Class/Migration/ScriptPatchs.php
+++ b/library/Class/Migration/ScriptPatchs.php
@@ -33,6 +33,12 @@ class Class_Migration_ScriptPatchs {
   }
 
 
+  public function runTo($patch_level) {
+    $this->migration = (new Class_Migration_Patchs());
+    $this->migration->setLastPatchNumber($patch_level)->acceptVisitor($this);
+  }
+
+
   public function visitPhpError($exception) {
       $this->echoError("Code : ".$exception->getCode()."\n");
       $this->echoError("Erreur :".$exception->getMessage());
diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..77ccda565d363f2e933d06110b8604b4af08de0a
--- /dev/null
+++ b/tests/db/UpgradeDBTest.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * BOKEH is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * BOKEH is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with BOKEH; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+abstract class UpgradeDBTestCase extends PHPUnit_Framework_TestCase {
+  const BACK_PATCH_LEVEL = 262;
+
+  protected static $_upgrade_done=false;
+
+  abstract public function prepare();
+
+  public function setUp() {
+    if (!self::$_upgrade_done) {
+
+    $this->_movePatchLevelTo(self::BACK_PATCH_LEVEL);
+    $this->_runAllPrepares();
+    self::$_upgrade_done = true;
+    }
+
+    (new Class_Migration_ScriptPatchs())->runTo($this->_getPatchLevel());
+  }
+
+
+  public function query($query) {
+    return Zend_Db_Table::getDefaultAdapter()->query($query);
+  }
+
+
+  public function _movePatchLevelTo($patch_level) {
+    $this->query('update variables set valeur=' . $patch_level . ' where clef="patch_level"');
+    $this->query('delete from patch_hash');
+  }
+
+
+  public function _runAllPrepares() {
+    foreach($this->_getSubclasses() as $subclass) {
+      (new $subclass())->prepare();
+    }
+  }
+
+
+  protected function _getPatchLevel() {
+    preg_match('/UpgradeDB_([0-9]+)_Test/',
+               get_class($this),
+               $matches);
+    return $matches[1];
+  }
+
+
+  protected function _getSubclasses() {
+    $result = array();
+    foreach (get_declared_classes() as $class) {
+      if (is_subclass_of($class, __CLASS__))
+        $result[] = $class;
+    }
+
+    return $result;
+  }
+}
+
+
+
+
+class UpgradeDB_263_Test extends UpgradeDBTestCase {
+  public function prepare() {
+    $this->query('delete from permission where code="CATEGORY"');
+  }
+
+
+  /** @test */
+  public function permissionCATEGORYShouldBeCreated() {
+    $data = $this->query('select * from permission where code="category" limit 1;')->fetch();
+    $this->assertArraySubset(['code' => 'CATEGORY',
+                              'module' => 'ARTICLE',
+                              'type' => 'Droits',
+                              'sorting' => 1,
+                              'description' => 'Créer des sous-catégories et des articles'],
+                             $data);
+  }
+}
+
+
+
+
+class UpgradeDB_267_Test extends UpgradeDBTestCase {
+  public function prepare() {
+    $this->query('delete from  bib_admin_var where clef="CNIL_CONSENT_ENABLE"');
+  }
+
+
+  /** @test */
+  public function varCNIL_CONSENT_ENABLE_ShouldEqualsOne() {
+    $data = $this->query('select valeur from bib_admin_var where clef="CNIL_CONSENT_ENABLE"')->fetch();
+    $this->assertEquals('1',
+                        $data['valeur']);
+  }
+}
+
+?>
\ No newline at end of file
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 8656f02449b8e9d4375db91e76b7560e92039efc..689b573449c14528b7e5c458cb241041b81123f6 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -7,6 +7,9 @@
     stopOnError="false"
     >
   <testsuites>
+    <testsuite name="DBTestSuite">
+      <directory>./db/</directory>
+    </testsuite>
     <testsuite name="ApplicationTestSuite">
       <directory>./application/</directory>
       <directory>./library/</directory>