From 98aa76be5673cb73d70acecd3c34c55567600889 Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Tue, 26 Sep 2017 13:26:13 +0200 Subject: [PATCH] WebshopApi: Syntax in Tests --- t/shop/shop_order.t | 26 ++++++++++++++------------ t/shop/shopware.t | 35 ++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/t/shop/shop_order.t b/t/shop/shop_order.t index 3c7007020..853322d0c 100644 --- a/t/shop/shop_order.t +++ b/t/shop/shop_order.t @@ -6,6 +6,9 @@ use Support::TestSetup; use Carp; use Test::Exception; use SL::Dev::ALL; +use SL::Dev::Part qw(new_part); +use SL::Dev::Shop qw(new_shop new_shop_part new_shop_order); +use SL::Dev::CustomerVendor qw(new_customer); use SL::DB::Shop; use SL::DB::ShopOrder; use SL::DB::ShopOrderItem; @@ -19,18 +22,17 @@ sub reset_state { clear_up(); - $shop = SL::Dev::Shop::new_shop->save; - $part = SL::Dev::Part::new_part->save; - $shop_part = SL::Dev::Shop::new_shop_part(part => $part, shop => $shop)->save; + $shop = new_shop->save; + $part = new_part->save; + $shop_part = new_shop_part(part => $part, shop => $shop)->save; $employee = SL::DB::Manager::Employee->current || croak "No employee"; - $customer = SL::Dev::CustomerVendor::new_customer( - name => 'Evil Inc', - street => 'Evil Street', - zipcode => '66666', - email => 'evil@evilinc.com' - )->save; + $customer = new_customer( name => 'Evil Inc', + street => 'Evil Street', + zipcode => '66666', + email => 'evil@evilinc.com' + )->save; } sub save_shorcontroller_to_string { @@ -67,7 +69,7 @@ reset_state(); my $shop_trans_id = 1; -$shop_order = SL::Dev::Shop::new_shop_order( +$shop_order = new_shop_order( shop => $shop, shop_trans_id => $shop_trans_id, amount => 59.5, @@ -96,7 +98,7 @@ is(scalar @{ $fuzzy_customers }, 1, 'found 1 matching customer'); is($fuzzy_customers->[0]->name, 'Evil Inc', 'matched customer Evil Inc'); note('adding a not-so-similar customer'); -my $customer_different = SL::Dev::CustomerVendor::new_customer( +my $customer_different = new_customer( name => "Different Name", street => 'Good Straet', # difference large enough from "Evil Street" zipcode => $customer->zipcode, @@ -106,7 +108,7 @@ $fuzzy_customers = $shop_order->check_for_existing_customers; is(scalar @{ $fuzzy_customers }, 1, 'still only found 1 matching customer (zipcode equal + street dissimilar'); note('adding a similar customer'); -my $customer_similar = SL::Dev::CustomerVendor::new_customer( +my $customer_similar = new_customer( name => "Different Name", street => 'Good Street', # difference not large enough from "Evil Street", street matches zipcode => $customer->zipcode, diff --git a/t/shop/shopware.t b/t/shop/shopware.t index fc030a6b2..3f7849811 100644 --- a/t/shop/shopware.t +++ b/t/shop/shopware.t @@ -6,6 +6,9 @@ use Support::TestSetup; use Carp; use Test::Exception; use SL::Dev::ALL; +use SL::Dev::Part qw(new_part); +use SL::Dev::Shop qw(new_shop new_shop_part); +use SL::Dev::CustomerVendor qw(new_customer); use SL::DB::Shop; use SL::DB::ShopOrder; use SL::DB::ShopOrderItem; @@ -21,27 +24,25 @@ sub reset_state { clear_up(); - $shop = SL::Dev::Shop::new_shop( connector => 'shopware', - last_order_number => 20000, - pricetype => 'brutto', - price_source => 'master_data', - taxzone_id => 1, - ); + $shop = new_shop( connector => 'shopware', + last_order_number => 20000, + pricetype => 'brutto', + price_source => 'master_data', + taxzone_id => 1, + ); $shopware = SL::Shop->new( config => $shop ); - $part = SL::Dev::Part::new_part( partnumber => 'SW10002', - description => 'TITANIUM CARBON GS 12m cm', - ); - $shop_part = SL::Dev::Shop::new_shop_part(part => $part, shop => $shop); + $part = new_part( partnumber => 'SW10002', + description => 'TITANIUM CARBON GS 12m cm', + ); + $shop_part = new_shop_part(part => $part, shop => $shop); $employee = SL::DB::Manager::Employee->current || croak "No employee"; - $customer = SL::Dev::CustomerVendor::new_customer( - name => 'Evil Inc', - street => 'Evil Street', - zipcode => '66666', - email => 'evil@evilinc.com' - )->save; - + $customer = new_customer( name => 'Evil Inc', + street => 'Evil Street', + zipcode => '66666', + email => 'evil@evilinc.com' + )->save; } sub get_json { -- 2.20.1