Revision c0b5a026
Von Werner Hahn vor mehr als 6 Jahren hinzugefügt
t/shop/shop_order.t | ||
---|---|---|
67 | 67 |
|
68 | 68 |
reset_state(); |
69 | 69 |
|
70 |
my $trgm = SL::DB::ShopOrder->check_trgm; |
|
71 |
|
|
70 | 72 |
my $shop_trans_id = 1; |
71 | 73 |
|
72 | 74 |
$shop_order = new_shop_order( |
... | ... | |
76 | 78 |
billing_lastname => 'Schmidt', |
77 | 79 |
billing_firstname => 'Sven', |
78 | 80 |
billing_company => 'Evil Inc', |
79 |
billing_street => 'Evil Street', |
|
81 |
billing_street => 'Evil Street 666',
|
|
80 | 82 |
billing_zipcode => $customer->zipcode, |
81 |
billing_email => $customer->email,
|
|
83 |
billing_email => 'email',
|
|
82 | 84 |
); |
83 | 85 |
|
84 | 86 |
my $shop_order_item = SL::DB::ShopOrderItem->new( |
... | ... | |
107 | 109 |
$fuzzy_customers = $shop_order->check_for_existing_customers; |
108 | 110 |
is(scalar @{ $fuzzy_customers }, 1, 'still only found 1 matching customer (zipcode equal + street dissimilar'); |
109 | 111 |
|
110 |
note('adding a similar customer');
|
|
112 |
note('adding 2 similar customers and 1 dissimilar but same email');
|
|
111 | 113 |
my $customer_similar = new_customer( |
112 | 114 |
name => "Different Name", |
113 |
street => 'Good Street', # difference not large enough from "Evil Street", street matches
|
|
115 |
street => 'Evil Street 666', # difference not large enough from "Evil Street", street matches
|
|
114 | 116 |
zipcode => $customer->zipcode, |
115 | 117 |
email => "foo", |
116 | 118 |
)->save; |
119 |
my $customer_similar_2 = new_customer( |
|
120 |
name => "Different Name", |
|
121 |
street => 'Evil Straet', # difference not large enough from "Evil Street", street matches |
|
122 |
zipcode => $customer->zipcode, |
|
123 |
email => "foofoo", |
|
124 |
)->save; |
|
125 |
my $customer_same_email = new_customer( |
|
126 |
name => "Different Name", |
|
127 |
street => 'Angel Way', # difference large enough from "Evil Street", street not matches , same email |
|
128 |
zipcode => $customer->zipcode, |
|
129 |
email => 'email', |
|
130 |
)->save; |
|
131 |
my $customers = SL::DB::Manager::Customer->get_all(); |
|
132 |
|
|
117 | 133 |
$fuzzy_customers = $shop_order->check_for_existing_customers; |
118 |
is(scalar @{ $fuzzy_customers }, 2, 'found 2 matching customers (zipcode equal + street similar)'); |
|
134 |
if($trgm){ |
|
135 |
is(scalar @{ $fuzzy_customers }, 4, 'found 4 matching customers (zipcode equal + street similar + same email) trgm_pg is installed'); |
|
136 |
}else{ |
|
137 |
is(scalar @{ $fuzzy_customers }, 3, 'found 3 matching customers (zipcode equal + %street% + same email) trgm_pg is not installed, could be 4 with trgm_pg'); |
|
138 |
} |
|
119 | 139 |
|
120 | 140 |
is($shop->description , 'testshop' , 'shop description ok'); |
121 | 141 |
is($shop_order->shop_id , $shop->id , "shop_id ok"); |
Auch abrufbar als: Unified diff
WebshopApi: Trigram Abhängigkeit aufgelöst.
Wird nur genutzt, wenn auch installiert
Tests dementsprechend angepasst und erweitert