From c17ae678248fd512f96302dfce4f745fd62a435d Mon Sep 17 00:00:00 2001
From: pbarroca <pbarroca@afi-sa.fr>
Date: Tue, 21 Jun 2016 15:12:59 +0200
Subject: [PATCH] rel #43603 : can choose to take barcodes from 949$6 in record
 profile modification

---
 VERSIONS_WIP/43603                               |  1 +
 .../controllers/DataProfileControllerTest.php    |  8 +++++++-
 cosmogramme/php/_init.php                        |  2 +-
 cosmogramme/sql/patch/patch_300.php              |  6 ++++++
 tests/db/UpgradeDBTest.php                       | 16 ++++++++++++++++
 5 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 VERSIONS_WIP/43603
 create mode 100644 cosmogramme/sql/patch/patch_300.php

diff --git a/VERSIONS_WIP/43603 b/VERSIONS_WIP/43603
new file mode 100644
index 00000000000..5b12579d7c7
--- /dev/null
+++ b/VERSIONS_WIP/43603
@@ -0,0 +1 @@
+ - ticket #43603 : Cosmogramme : possibilité de prendre les code barre exemplaires dans le champ 949$6
\ No newline at end of file
diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
index 04b19ac7fc9..a6bf4c2c659 100644
--- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
+++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
@@ -61,7 +61,7 @@ abstract class Cosmo_DataProfileControllerTestCase extends CosmoControllerTestCa
     $this->fixture('Class_CosmoVar',
                    ['id' => 'champ_code_barres',
                     'valeur' => null,
-                    'liste' => "f:995$f\r\nh:995$h\r\nb:995$b\r\n997:997$a\r\n852:852$g\r\na:995$a\r\n999:999$i\r\n996:996$f"]);
+                    'liste' => "f:995$f\r\nh:995$h\r\nb:995$b\r\n997:997$a\r\n852:852$g\r\na:995$a\r\n999:999$i\r\n996:996$f\r\n949:949$6"]);
 
     $this->fixture('Class_CosmoVar',
                    ['id' => 'champ_cote',
@@ -259,6 +259,12 @@ class Cosmo_DataProfileControllerEditUnimarcKohaTest extends Cosmo_DataProfileCo
   }
 
 
+  /** @test */
+  public function itemCodebarreIn949Dollar6ShouldBePresent() {
+    $this->assertXPath('//form//select[@id="champ_code_barres"]/option[@value="949"][@label="949$6"]');
+  }
+
+
   /** @test */
   public function itemCoteShouldBePresent() {
     $this->assertXPath('//form//select[@id="champ_cote"]/option[@value="k"][@selected]');
diff --git a/cosmogramme/php/_init.php b/cosmogramme/php/_init.php
index 5a7e2ea214f..5a406255eed 100644
--- a/cosmogramme/php/_init.php
+++ b/cosmogramme/php/_init.php
@@ -1,7 +1,7 @@
 <?php
 error_reporting(E_ERROR | E_PARSE);
 
-define("PATCH_LEVEL","299");
+define("PATCH_LEVEL","300");
 
 define("APPLI","cosmogramme");
 define("COSMOPATH", "/var/www/html/vhosts/opac2/www/htdocs");
diff --git a/cosmogramme/sql/patch/patch_300.php b/cosmogramme/sql/patch/patch_300.php
new file mode 100644
index 00000000000..312c6372373
--- /dev/null
+++ b/cosmogramme/sql/patch/patch_300.php
@@ -0,0 +1,6 @@
+<?php
+$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
+
+try {
+  $adapter->query('update variables set liste=\'f:995$f\r\nh:995$h\r\nb:995$b\r\n997:997$a\r\n852:852$g\r\na:995$a\r\n999:999$i\r\n996:996$f\r\n949:949$6\' where clef=\'champ_code_barres\'');
+} catch(Exception $e) {}
diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
index 57a23094e94..d1a37331846 100644
--- a/tests/db/UpgradeDBTest.php
+++ b/tests/db/UpgradeDBTest.php
@@ -755,4 +755,20 @@ class UpgradeDB_299_Test extends UpgradeDBTestCase {
     $this->assertEquals('https://websvc.afi-sa.net/afi_opac_services/main.php',
                         Class_CosmoVar::get('url_services'));
   }
+}
+
+
+
+class UpgradeDB_300_Test extends UpgradeDBTestCase {
+  public function prepare() {
+    $this->query('update variables set liste=\'f:995$f\r\nh:995$h\r\nb:995$b\r\n997:997$a\r\n852:852$g\r\na:995$a\r\n999:999$i\r\n996:996$f\' where clef=\'champ_code_barres\'');
+  }
+
+
+  /** @test */
+  public function barcodeFieldsShouldContains949Dollar6() {
+    $this->assertContains("\r\n" . '949:949$6',
+                          $this->query('select liste from variables where clef=\'champ_code_barres\'')
+                          ->fetch()['liste']);
+  }
 }
\ No newline at end of file
-- 
GitLab