public function testReviewingBatchActivation() { list($category_id, $account_id, $brand_id, $notification, $otherProduct) = $this->startData(); $job = new ReviewGammaNotification($notification); $this->handleJob($job); //new account -> should not contain actual gamma // -> should have the selection // -> should have the notifications for products within the subscribed accounts $subscriptions = app('Modules\\Shop\\Gamma\\GammaSubscriptionManager'); $products = Product::where('brand_id', $brand_id)->whereHas('categories', function ($q) use($category_id) { $q->where('category_id', $category_id); })->whereIn('account_id', $subscriptions->subscribedIds(Account::find($account_id))); foreach ($products as $product) { $this->seeInDatabase('product_gamma_notifications', ['product_id' => $product->id, 'brand_id' => $product->brand_id, 'category_id' => $category_id, 'account_id' => $account_id, 'type' => 'activate']); $this->notSeeInDatabase('product_gamma', ['product_id' => $product->id, 'account_id' => $account_id]); } $this->notSeeInDatabase('product_gamma_notifications', ['product_id' => $otherProduct->id, 'brand_id' => $otherProduct->brand_id, 'category_id' => $category_id, 'account_id' => $account_id, 'type' => 'activate']); $this->seeInDatabase('product_gamma_selections', ['account_id' => $account_id, 'category_id' => $category_id, 'brand_id' => $brand_id]); $this->notSeeInDatabase('product_gamma_notifications', ['id' => $notification->id]); }
/** * @return array */ protected function setupForDeactivation($use_product) { list($account_id, $brand_id, $category_id, $notification) = $this->startData($use_product, 'deactivate'); $products = Product::where(['brand_id' => $brand_id])->get(); $this->database(new GammaSelection())->insert(['account_id' => $account_id, 'brand_id' => $brand_id, 'category_id' => $category_id]); foreach ($products as $product) { $id = $this->database(new ProductSelection())->insertGetId(['account_id' => $account_id, 'brand_id' => $brand_id, 'product_id' => $product->id]); $this->database(new ProductCategorySelection())->insert(['selection_id' => $id, 'category_id' => $category_id]); } return [$account_id, $brand_id, $category_id, $notification, $products]; }