From d13905521a15f54c454c52db695f846722eec82c Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Tue, 10 May 2022 10:28:55 +0200
Subject: [PATCH] add SQL tests to numilog migration

---
 tests/db/UpgradeDBTest.php | 59 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 57 insertions(+), 2 deletions(-)

diff --git a/tests/db/UpgradeDBTest.php b/tests/db/UpgradeDBTest.php
index f3d9dfbb58f..0e5b7063fc8 100644
--- a/tests/db/UpgradeDBTest.php
+++ b/tests/db/UpgradeDBTest.php
@@ -4397,10 +4397,65 @@ class UpgradeDB_428_Test extends UpgradeDBTestCase {
 
 
 class UpgradeDB_429_Test extends UpgradeDBTestCase {
-  public function prepare() {}
+
+  public function prepare() {
+    $this
+      ->silentQuery('INSERT INTO bib_admin_var (clef, valeur) VALUES ("NUMILOG_OAI_IDBIB", "890")')
+      ->silentQuery('INSERT INTO album (type_doc_id, titre) VALUES ("106", "update Me")')
+      ->silentQuery('INSERT INTO codif_type_doc (type_doc_id) VALUES ("106")')
+      ->silentQuery('DELETE FROM codif_type_doc where type_doc_id="Numilog"');
+  }
+
+
+  /** @test */
+  public function albumUpdateMeDocTypeIdShouldBeNumilog() {
+    $row = $this->query('select type_doc_id from album where titre="update Me"')
+                ->fetch();
+
+    $this->assertEquals('Numilog', $row['type_doc_id'] ?? '');
+  }
+
 
   /** @test */
-  public function placeholderForNumilogMigrationPatch() {}
+  public function adminVarNumilogOaiIdBibShouldHaveBeenRemove() {
+    $row = $this->query('select valeur from bib_admin_var where clef="NUMILOG_OAI_IDBIB"')
+                ->fetch();
+    $this->assertEquals('', $row['valeur'] ?? '');
+  }
+
+
+  /** @test */
+  public function adminVarNumilogKeyShouldHaveBeenCreatedWith890() {
+    $row = $this->query('select valeur from bib_admin_var where clef="Numilog_KEY"')
+                ->fetch();
+    $this->assertEquals('890', $row['valeur'] ?? '');
+  }
+
+
+  /** @test */
+  public function codifTypeDoc106ShouldHaveBeenDelete() {
+    $row = $this->query('select type_doc_id from codif_type_doc where type_doc_id="106"')
+                ->fetch();
+    $this->assertEquals('', $row['type_doc_id'] ?? '');
+  }
+
+
+  /** @test */
+  public function codifTypeDocNumilogShouldHaveBeenCreated() {
+    $row = $this->query('select type_doc_id from codif_type_doc where type_doc_id="Numilog"')
+                ->fetch();
+    $this->assertEquals('Numilog', $row['type_doc_id'] ?? '');
+  }
+
+
+  public function tearDown() {
+    $this
+      ->silentQuery('delete from codif_type_doc where type_doc_id="Numilog"')
+      ->silentQuery('delete from album where titre="update Me"')
+      ->silentQuery('delete from bib_admin_var where clef="NUMILOG_OAI_IDBIB"')
+      ->silentQuery('delete from bib_admin_var where clef="Numilog_Key"');
+    parent::tearDown();
+  }
 }
 
 
-- 
GitLab