Bug 22368: Make sure the tests will always pass
[koha.git] / t / Prices.t
index c5c744f..4039233 100644 (file)
@@ -8,33 +8,35 @@ use Module::Load::Conditional qw/check_install/;
 
 BEGIN {
     if ( check_install( module => 'Test::DBIx::Class' ) ) {
-        plan tests => 17;
+        plan tests => 16;
     } else {
         plan skip_all => "Need Test::DBIx::Class"
     }
 }
 
 use_ok('C4::Acquisition');
-use_ok('C4::Bookseller');
 use_ok('C4::Context');
 use_ok('Koha::Number::Price');
 
 t::lib::Mocks::mock_preference( 'gist', '0.02|0.05|0.196' );
 
-use Test::DBIx::Class {
-    schema_class => 'Koha::Schema',
-    connect_info => ['dbi:SQLite:dbname=:memory:','',''],
-    connect_opts => { name_sep => '.', quote_char => '`', },
-    fixture_class => '::Populate',
-}, 'Currency' ;
+use Test::DBIx::Class;
 
 my $db = Test::MockModule->new('Koha::Database');
 $db->mock( _new_schema => sub { return Schema(); } );
+Koha::Database::flush_schema_cache();
 
 fixtures_ok [
     Currency => [
         [ qw/ currency symbol rate active / ],
-        [[ 'my_cur', '€', 1, 1, ]],
+        [ 'my_cur', '€', 1, 1, ],
+    ],
+    Aqbookseller => [
+        [ qw/ id name listincgst invoiceincgst / ],
+        [ 1, '0 0', 0, 0 ],
+        [ 2, '0 1', 0, 1 ],
+        [ 3, '1 0', 1, 0 ],
+        [ 4, '1 1', 1, 1 ],
     ],
 ], 'add currency fixtures';
 
@@ -48,12 +50,6 @@ for my $currency_format ( qw( US FR ) ) {
     t::lib::Mocks::mock_preference( 'CurrencyFormat', $currency_format );
     subtest 'Configuration 1: 0 0' => sub {
         plan tests => 8;
-        $bookseller_module->mock(
-            'fetch',
-            sub {
-                return { listincgst => 0, invoiceincgst => 0 };
-            }
-        );
 
         my $biblionumber_0_0 = 42;
 
@@ -74,7 +70,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_0_0 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_0_0,
-                booksellerid => 'just_something',
+                booksellerid => 1,
                 ordering     => 1,
             }
         );
@@ -113,7 +109,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_0_0->{tax_value},
+                got      => $order_0_0->{tax_value_on_ordering},
                 expected => 7.38,
                 conf     => '0 0',
                 field    => 'tax_value'
@@ -123,7 +119,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_0_0 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_0_0,
-                booksellerid => 'just_something',
+                booksellerid => 1,
                 receiving    => 1,
             }
         );
@@ -146,7 +142,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_0_0->{tax_value},
+                got      => $order_0_0->{tax_value_on_receiving},
                 expected => 7.38,
                 conf     => '0 0',
                 field    => 'tax_value'
@@ -156,12 +152,6 @@ for my $currency_format ( qw( US FR ) ) {
 
     subtest 'Configuration 1: 1 1' => sub {
         plan tests => 8;
-        $bookseller_module->mock(
-            'fetch',
-            sub {
-                return { listincgst => 1, invoiceincgst => 1 };
-            }
-        );
 
         my $biblionumber_1_1 = 43;
         my $order_1_1        = {
@@ -182,7 +172,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_1_1 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_1_1,
-                booksellerid => 'just_something',
+                booksellerid => 4,
                 ordering     => 1,
             }
         );
@@ -221,7 +211,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_1_1->{tax_value},
+                got      => $order_1_1->{tax_value_on_ordering},
                 expected => 7.03,
                 conf     => '1 1',
                 field    => 'tax_value'
@@ -231,7 +221,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_1_1 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_1_1,
-                booksellerid => 'just_something',
+                booksellerid => 4,
                 receiving    => 1,
             }
         );
@@ -254,7 +244,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_1_1->{tax_value},
+                got      => $order_1_1->{tax_value_on_receiving},
                 expected => 7.03,
                 conf     => '1 1',
                 field    => 'tax_value'
@@ -264,12 +254,6 @@ for my $currency_format ( qw( US FR ) ) {
 
     subtest 'Configuration 1: 1 0' => sub {
         plan tests => 8;
-        $bookseller_module->mock(
-            'fetch',
-            sub {
-                return { listincgst => 1, invoiceincgst => 0 };
-            }
-        );
 
         my $biblionumber_1_0 = 44;
         my $order_1_0        = {
@@ -290,7 +274,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_1_0 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_1_0,
-                booksellerid => 'just_something',
+                booksellerid => 3,
                 ordering     => 1,
             }
         );
@@ -329,7 +313,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_1_0->{tax_value},
+                got      => $order_1_0->{tax_value_on_ordering},
                 expected => 7.03,
                 conf     => '1 0',
                 field    => 'tax_value'
@@ -339,7 +323,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_1_0 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_1_0,
-                booksellerid => 'just_something',
+                booksellerid => 3,
                 receiving    => 1,
             }
         );
@@ -362,7 +346,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_1_0->{tax_value},
+                got      => $order_1_0->{tax_value_on_receiving},
                 expected => 7.03,
                 conf     => '1 0',
                 field    => 'tax_value'
@@ -372,12 +356,6 @@ for my $currency_format ( qw( US FR ) ) {
 
     subtest 'Configuration 1: 0 1' => sub {
         plan tests => 8;
-        $bookseller_module->mock(
-            'fetch',
-            sub {
-                return { listincgst => 0, invoiceincgst => 1 };
-            }
-        );
 
         my $biblionumber_0_1 = 45;
         my $order_0_1        = {
@@ -398,7 +376,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_0_1 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_0_1,
-                booksellerid => 'just_something',
+                booksellerid => 2,
                 ordering     => 1,
             }
         );
@@ -437,7 +415,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_0_1->{tax_value},
+                got      => $order_0_1->{tax_value_on_ordering},
                 expected => 7.38,
                 conf     => '0 1',
                 field    => 'tax_value'
@@ -447,7 +425,7 @@ for my $currency_format ( qw( US FR ) ) {
         $order_0_1 = C4::Acquisition::populate_order_with_prices(
             {
                 order        => $order_0_1,
-                booksellerid => 'just_something',
+                booksellerid => 2,
                 receiving    => 1,
             }
         );
@@ -470,7 +448,7 @@ for my $currency_format ( qw( US FR ) ) {
         );
         compare(
             {
-                got      => $order_0_1->{tax_value},
+                got      => $order_0_1->{tax_value_on_receiving},
                 expected => 7.38,
                 conf     => '0 1',
                 field    => 'tax_value'