Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Cleaned up test object
Browse files Browse the repository at this point in the history
  • Loading branch information
gnikyt committed Jun 27, 2018
1 parent bef44d6 commit f0d8891
Showing 1 changed file with 132 additions and 110 deletions.
242 changes: 132 additions & 110 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,31 +68,42 @@ protected function seedDatabase()

protected function createShops()
{
// Paid shop, not grandfathered
$shop = new Shop();
$shop->shopify_domain = 'example.myshopify.com';
$shop->shopify_token = '1234';
$shop->save();

// Non-paid shop, grandfathered
$shop = new Shop();
$shop->shopify_domain = 'grandfathered.myshopify.com';
$shop->shopify_token = '1234';
$shop->grandfathered = true;
$shop->save();

// New shop... non-paid, not grandfathered
$shop = new Shop();
$shop->shopify_domain = 'new-shop.myshopify.com';
$shop->shopify_token = '1234';
$shop->save();
$shops = [
// Paid shop, not grandfathered
[
'shopify_domain' => 'example.myshopify.com',
'shopify_token' => '1234',
],

// Non-paid shop, grandfathered
[
'shopify_domain' => 'grandfathered.myshopify.com',
'shopify_token' => '1234',
'grandfathered' => true,
],

// New shop... non-paid, not grandfathered
[
'shopify_domain' => 'new-shop.myshopify.com',
'shopify_token' => '1234',
],

// New shop... no token, not grandfathered
[
'shopify_domain' => 'no-token-shop.myshopify.com',
],
];

// New shop... no token, not grandfathered
$shop = new Shop();
$shop->shopify_domain = 'no-token-shop.myshopify.com';
$shop->save();
// Build the shops
foreach ($shops as $shopData) {
$shop = new Shop();
foreach ($shopData as $key => $value) {
$shop->{$key} = $value;
}
$shop->save();
}

// Trashed shop
// Special trashed shop
$shop = new Shop();
$shop->shopify_domain = 'trashed-shop.myshopify.com';
$shop->save();
Expand All @@ -101,92 +112,103 @@ protected function createShops()

public function createCharges()
{
// Test = true, status = accepted, trial = 7, active trial = no
$charge = new Charge();
$charge->charge_id = 98298298;
$charge->test = true;
$charge->name = 'Test Plan';
$charge->status = 'accepted';
$charge->type = 1;
$charge->price = 15.00;
$charge->trial_days = 7;
$charge->trial_ends_on = Carbon::createFromDate(2018, 6, 3, 'UTC')->addWeeks(1)->format('Y-m-d');
$charge->shop_id = Shop::where('shopify_domain', 'example.myshopify.com')->first()->id;
$charge->save();

// Test = false, status = active, trial = 7, active trial = yes
$charge = new Charge();
$charge->charge_id = 67298298;
$charge->test = false;
$charge->name = 'Base Plan';
$charge->status = 'active';
$charge->type = 1;
$charge->price = 25.00;
$charge->trial_days = 7;
$charge->trial_ends_on = Carbon::today()->addDays(2)->format('Y-m-d');
$charge->shop_id = Shop::where('shopify_domain', 'example.myshopify.com')->first()->id;
$charge->save();

// Test = false, status = active, trial = 7, active trial = no
$charge = new Charge();
$charge->charge_id = 78378873;
$charge->test = false;
$charge->name = 'Base Plan Old';
$charge->status = 'active';
$charge->type = 1;
$charge->price = 25.00;
$charge->trial_days = 7;
$charge->trial_ends_on = Carbon::today()->subWeeks(4)->format('Y-m-d');
$charge->shop_id = Shop::where('shopify_domain', 'example.myshopify.com')->first()->id;
$charge->save();

// Test = false, status = active, trial = 0
$charge = new Charge();
$charge->charge_id = 89389389;
$charge->test = false;
$charge->name = 'Base Plan Old Non-Trial';
$charge->status = 'active';
$charge->type = 1;
$charge->price = 25.00;
$charge->trial_days = 0;
$charge->shop_id = Shop::where('shopify_domain', 'example.myshopify.com')->first()->id;
$charge->save();

// Test = false, status = declined, trial = 7, active trial = true
$charge = new Charge();
$charge->charge_id = 78378378378;
$charge->test = false;
$charge->name = 'Base Plan Declined';
$charge->status = 'declined';
$charge->type = 1;
$charge->price = 25.00;
$charge->shop_id = Shop::where('shopify_domain', 'no-token-shop.myshopify.com')->first()->id;
$charge->save();

// Test = false, status = cancelled
$charge = new Charge();
$charge->charge_id = 783873873;
$charge->test = false;
$charge->name = 'Base Plan Cancelled';
$charge->status = 'active';
$charge->type = 1;
$charge->price = 25.00;
$charge->shop_id = Shop::where('shopify_domain', 'example.myshopify.com')->first()->id;
$charge->cancelled_on = Carbon::today()->format('Y-m-d');
$charge->save();

// Test = false, status = cancelled, trial = 7
$charge = new Charge();
$charge->charge_id = 928736721;
$charge->test = false;
$charge->name = 'Base Plan Cancelled';
$charge->status = 'cancelled';
$charge->type = 1;
$charge->price = 25.00;
$charge->trial_days = 7;
$charge->trial_ends_on = Carbon::today()->addWeeks(1)->format('Y-m-d');
$charge->cancelled_on = Carbon::today()->addDays(2)->format('Y-m-d');
$charge->shop_id = Shop::withTrashed()->where('shopify_domain', 'trashed-shop.myshopify.com')->first()->id;
$charge->save();
$charges = [
// Test = true, status = accepted, trial = 7, active trial = no
[
'charge_id' => 98298298,
'test' => true,
'name' => 'Test Plan',
'status' => 'accepted',
'type' => 1,
'price' => 15.00,
'trial_days' => 7,
'trial_ends_on' => Carbon::createFromDate(2018, 6, 3, 'UTC')->addWeeks(1)->format('Y-m-d'),
'shop_id' => Shop::where('shopify_domain', 'example.myshopify.com')->first()->id,
],

// Test = false, status = active, trial = 7, active trial = yes
[
'charge_id' => 67298298,
'test' => false,
'name' => 'Base Plan',
'status' => 'active',
'type' => 1,
'price' => 25.00,
'trial_days' => 7,
'trial_ends_on' => Carbon::today()->addDays(2)->format('Y-m-d'),
'shop_id' => Shop::where('shopify_domain', 'example.myshopify.com')->first()->id,
],

// Test = false, status = active, trial = 7, active trial = no
[
'charge_id' => 78378873,
'test' => false,
'name' => 'Base Plan Old',
'status' => 'active',
'type' => 1,
'price' => 25.00,
'trial_days' => 7,
'trial_ends_on' => Carbon::today()->subWeeks(4)->format('Y-m-d'),
'shop_id' => Shop::where('shopify_domain', 'example.myshopify.com')->first()->id,
],

// Test = false, status = active, trial = 0
[
'charge_id' => 89389389,
'test' => false,
'name' => 'Base Plan Old Non-Trial',
'status' => 'active',
'type' => 1,
'price' => 25.00,
'trial_days' => 0,
'shop_id' => Shop::where('shopify_domain', 'example.myshopify.com')->first()->id,
],

// Test = false, status = declined, trial = 7, active trial = true
[
'charge_id' => 78378378378,
'test' => false,
'name' => 'Base Plan Declined',
'status' => 'declined',
'type' => 1,
'price' => 25.00,
'shop_id' => Shop::where('shopify_domain', 'no-token-shop.myshopify.com')->first()->id,
],

// Test = false, status = cancelled
[
'charge_id' => 783873873,
'test' => false,
'name' => 'Base Plan Cancelled',
'status' => 'active',
'type' => 1,
'price' => 25.00,
'shop_id' => Shop::where('shopify_domain', 'example.myshopify.com')->first()->id,
'cancelled_on' => Carbon::today()->format('Y-m-d'),
],

// Test = false, status = cancelled, trial = 7
[
'charge_id' => 928736721,
'test' => false,
'name' => 'Base Plan Cancelled',
'status' => 'cancelled',
'type' => 1,
'price' => 25.00,
'trial_days' => 7,
'trial_ends_on' => Carbon::today()->addWeeks(1)->format('Y-m-d'),
'cancelled_on' => Carbon::today()->addDays(2)->format('Y-m-d'),
'shop_id' => Shop::withTrashed()->where('shopify_domain', 'trashed-shop.myshopify.com')->first()->id,
],
];

// Build the charges
foreach ($charges as $chargeData) {
$charge = new Charge();
foreach ($chargeData as $key => $value) {
$charge->{$key} = $value;
}
$charge->save();
}
}
}

0 comments on commit f0d8891

Please # to comment.