Bug 22824: Add tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 11 Feb 2021 09:01:02 +0000 (10:01 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 4 Mar 2021 15:18:42 +0000 (16:18 +0100)
Writing some tests to see how things are working currently

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/data/syspref.pref [new file with mode: 0644]
t/db_dependent/yaml.t [new file with mode: 0755]

diff --git a/t/db_dependent/data/syspref.pref b/t/db_dependent/data/syspref.pref
new file mode 100644 (file)
index 0000000..c5cee1e
--- /dev/null
@@ -0,0 +1,28 @@
+Test:
+    Testing:
+        -
+            - Do it
+            - pref: syspref_1
+              choices:
+                  on: certainly
+                  off: "I don't think so"
+        -
+            - pref: syspref_2
+              choices:
+                  '': Do
+                  dont: "Don't do"
+                  0: "really don't do"
+            - it.
+        -
+            - "We love unicode"
+            - pref: syspref_3
+              choices:
+                  ★ : ❤️
+                  no: "Not really"
+        -
+            - "List of fields"
+            - pref: syspref_4
+              choices:
+                  020: 020
+                  "020": "020"
+                  "123": "123"
diff --git a/t/db_dependent/yaml.t b/t/db_dependent/yaml.t
new file mode 100755 (executable)
index 0000000..177ce18
--- /dev/null
@@ -0,0 +1,78 @@
+use Modern::Perl;
+use Test::More;
+
+use YAML::Syck;
+use Template;
+use utf8;
+
+$YAML::Syck::ImplicitTyping = 1;
+$YAML::Syck::ImplicitUnicode = 1;
+
+my $template = Template->new( ENCODING => 'UTF-8' );
+
+my $vars;
+my $output;
+$template->process( 't/db_dependent/data/syspref.pref', $vars, \$output );
+
+use Data::Printer colored => 1; warn p $output;
+
+my $yaml = YAML::Syck::Load( $output );
+my $syspref_1 = $yaml->{Test}->{Testing}->[0];
+my $syspref_2 = $yaml->{Test}->{Testing}->[1];
+my $syspref_3 = $yaml->{Test}->{Testing}->[2];
+my $syspref_4 = $yaml->{Test}->{Testing}->[3];
+is_deeply(
+    $syspref_1,
+    [
+        "Do it",
+        {
+            choices => {
+                1  => "certainly",
+                '' => "I don't think so"
+            },
+            pref => "syspref_1"
+        }
+    ]
+);
+is_deeply(
+    $syspref_2,
+    [
+        {
+            choices => {
+                0    => "really don't do",
+                ''   => "Do",
+                dont => "Don't do"
+            },
+            pref => "syspref_2"
+        },
+        "it."
+    ]
+);
+is_deeply(
+    $syspref_3,
+    [
+        "We love unicode",
+        {
+            choices => {
+                ''    => "Not really",
+                '★' => "❤️"
+            },
+            pref => "syspref_3"
+        }
+    ],
+);
+is_deeply(
+    $syspref_4,
+    [
+        "List of fields",
+        {
+            choices => {
+                16    => 16,
+                "020" => "020",
+                123   => 123
+            },
+            pref => "syspref_4"
+        }
+    ]
+);
+done_testing;