Skip to content

Commit

Permalink
Fix for failing tests (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
divya-intelli authored Dec 2, 2022
1 parent 3fd2894 commit 87a6478
Show file tree
Hide file tree
Showing 20 changed files with 10 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public function testAddCreditButtonPermissionsOnPrepaidBalancePage() {

// Create and sign in a user with no add credit permissions.
$this->developer = $this->signIn(['view own prepaid balance']);
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ protected function setUp(): void {
* @covers \Drupal\apigee_m10n_add_credit\AddCreditService::apigeeM10nPrepaidBalanceListAlter
*/
public function testAddCreditButtonForCurrency() {
$this->warmOrganizationCache();

// Configure an add credit product for USD.
// There should be an add credit button for usd but NOT for aud.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AddCreditPrepaidBalanceButtonTest extends AddCreditFunctionalJavascriptTes
protected function setUp(): void {
parent::setUp();

$this->warmOrganizationCache();
$this->developer = $this->signIn([
'view own prepaid balance',
'add credit to own developer prepaid balance',
Expand Down Expand Up @@ -86,7 +87,6 @@ protected function setUp(): void {
public function testAddCreditButton() {
$this->setAddCreditProductForCurrencyId($this->product, 'usd');

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class AddCreditPrepaidBalanceToAnyDeveloperTest extends AddCreditFunctionalJavas
protected function setUp(): void {
parent::setUp();

$this->warmOrganizationCache();
$this->accountUser = $this->signIn([
'view own prepaid balance',
'add credit to own developer prepaid balance',
Expand Down Expand Up @@ -97,7 +98,6 @@ public function testAddCreditToAnyDeveloper() {
]);

$this->setAddCreditProductForCurrencyId($this->product, 'usd');
$this->warmOrganizationCache();

// Load authenticated developer.
$this->queueDeveloperResponse($this->accountUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ protected function signIn(array $permissions = [], $billingType = 'postpaid'): U
->set('billing.billingtype', strtolower($billingType))
->save();

$this->warmApigeexOrganizationCache();

$account = $this->createAccount($permissions, TRUE, '', ['billing_type' => strtoupper($billingType)]);
$this->drupalLogin($account);
return $account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ protected function assertTeamPlansPage() {
}
}

// Queue up a monetized org response.
$this->stack->queueMockResponse('get_monetized_org');

// Queue the product bundle response.
$this->stack->queueMockResponse(['get_monetization_packages' => ['packages' => $product_bundles]]);
foreach ($rate_plans as $product_bundle_id => $plans) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ protected function setUp(): void {
$this->rate_plan = $this->createRatePlan($this->product_bundle);
$this->purchased_plan = $this->createTeamPurchasedPlan($this->team, $this->rate_plan);

$this->warmOrganizationCache();
$this->warmTnsCache();
$this->warmTeamTnsCache($this->team);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/src/Functional/BillingDetailsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class BillingDetailsTest extends MonetizationFunctionalTestBase {
protected function setUp(): void {
parent::setUp();

$this->warmOrganizationCache();

// If the user doesn't have the "view any monetization billing details"
// permission, they should get access denied.
$this->developer = $this->createAccount([]);
Expand All @@ -60,7 +62,6 @@ protected function setUp(): void {
* @throws \Exception
*/
public function testBillingDetailsPageView() {
$this->warmOrganizationCache();
$this->stack->queueMockResponse([
'developer_mint' => [
'mail' => ['value' => $this->developer->getEmail()],
Expand Down
1 change: 0 additions & 1 deletion tests/src/Functional/NavigationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public function testNavigation() {
$this->assertCssElementContains('.block-menu.navigation.menu--main ', 'Pricing & plans');
$this->assertCssElementContains('.block-menu.navigation.menu--account', 'My account');

$this->warmOrganizationCache();
$product_bundle = $this->createProductBundle();
$rate_plan = $this->createRatePlan($product_bundle);
$purchased_plan = $this->createPurchasedPlan($this->developer, $rate_plan);
Expand Down
8 changes: 0 additions & 8 deletions tests/src/Functional/PrepaidBalanceCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class PrepaidBalanceCacheTest extends MonetizationFunctionalTestBase {
*/
protected function setUp(): void {
parent::setUp();

$this->developer = $this->createAccount([
'view own prepaid balance',
'download prepaid balance reports',
Expand All @@ -89,7 +88,6 @@ public function testNoPermission() {
$authenticated_role->save();

// User cannot refresh prepaid balance.
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueResponses();
$this->drupalGet(Url::fromRoute('apigee_monetization.billing', [
Expand All @@ -108,7 +106,6 @@ public function testRefreshOwnPrepaidBalancePermission() {
$this->grantPermissions(Role::load(reset($user_roles)), ['refresh own prepaid balance']);

// User can refresh own account.
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->assertRefreshPrepaidBalanceForUser($this->developer);
}
Expand All @@ -125,7 +122,6 @@ public function testRefreshAnyPrepaidBalancePermission() {

// User can refresh another user account.
$other_user = $this->createAccount();
$this->warmOrganizationCache();
$this->queueDeveloperResponse($other_user);
$this->assertRefreshPrepaidBalanceForUser($other_user);
}
Expand All @@ -139,7 +135,6 @@ public function testPrepaidBalanceCacheIds() {

// Visit the prepaid balance page.
$expected_expiration_time = time() + static::CACHE_MAX_AGE;
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueResponses();
$this->drupalGet(Url::fromRoute('apigee_monetization.billing', [
Expand All @@ -156,7 +151,6 @@ public function testPrepaidBalanceCacheIds() {
*/
public function testPrepaidBalanceCacheIdsRebuild() {
// Visit the prepaid balance page to set the caches.
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueResponses();
$this->drupalGet(Url::fromRoute('apigee_monetization.billing', [
Expand Down Expand Up @@ -187,7 +181,6 @@ public function testPrepaidBalanceCacheIdsRebuild() {
public function testPrepaidBalanceCacheTags() {
$this->checkDriverHeaderSupport();

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueResponses();
$this->drupalGet(Url::fromRoute('apigee_monetization.billing', [
Expand All @@ -207,7 +200,6 @@ public function testPrepaidBalanceCacheDisable() {
->save();

// Visit the prepaid balance page.
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->queueResponses();
$this->drupalGet(Url::fromRoute('apigee_monetization.billing', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function testAccountWithNoReports() {
$month = $this->lastMonth->format('F');
$month_numeric = $this->lastMonth->format('m');

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->account);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down Expand Up @@ -113,7 +112,6 @@ public function testDateWithNoReport() {
$month = $this->lastMonth->format('F');
$month_numeric = $this->lastMonth->format('m');

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->account);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down Expand Up @@ -150,7 +148,6 @@ public function testValidAccountAndDate() {
$year = $this->lastMonth->format('Y');
$month_numeric = $this->lastMonth->format('m');

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->account);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down
1 change: 0 additions & 1 deletion tests/src/Functional/PrepaidBalanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function testPrepaidBalancesView() {

$this->drupalLogin($this->developer);

$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->developer);
$this->stack->queueMockResponse([
'get-prepaid-balances' => [
Expand Down
2 changes: 0 additions & 2 deletions tests/src/Functional/PricingAndPlansFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function testPricingAndPlansForNonAdmin() {
$this->accountUser = $this->createAccount(['view rate_plan']);
$this->drupalLogin($this->accountUser);

$this->warmOrganizationCache();
$this->queuePackagesAndPlansResponse();

$this->drupalGet(Url::fromRoute('apigee_monetization.plans', [
Expand All @@ -74,7 +73,6 @@ public function testPricingAndPlansForAdmin() {
$this->accountAdmin = $this->createAccount(['view rate_plan', 'administer apigee monetization']);
$this->drupalLogin($this->accountAdmin);

$this->warmOrganizationCache();
$this->queuePackagesAndPlansResponse();

$this->drupalGet(Url::fromRoute('apigee_monetization.plans', [
Expand Down
1 change: 0 additions & 1 deletion tests/src/Functional/PurchasedPlanListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function testPurchasedPlanListView() {
$rate_plan = $this->createRatePlan($product_bundle);
$purchased_plan = $this->createPurchasedPlan($this->developer, $rate_plan);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down
6 changes: 0 additions & 6 deletions tests/src/Functional/PurchasedPlanStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ protected function setUp(): void {
public function testPurchasedPlanActiveStatus() {
$purchased_plan = $this->createPurchasedPlan($this->developer, $this->ratePlan);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down Expand Up @@ -115,7 +114,6 @@ public function testPurchasedPlanEndedStatus() {
$end_date->setTimezone($purchased_plan->getRatePlan()->getOrganization()->getTimezone());
$purchased_plan->setEndDate($end_date);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down Expand Up @@ -143,7 +141,6 @@ public function testPurchasedPlanGetFutureStatus() {
$start_date = new \DateTimeImmutable('today +2 day', new \DateTimeZone($this->orgDefaultTimezone));
$purchased_plan->setStartDate($start_date);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down Expand Up @@ -173,7 +170,6 @@ public function testActivePurchasedPlanWithChangedTimezone() {

$purchased_plan = $this->createPurchasedPlan($this->developer, $this->ratePlan);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down Expand Up @@ -211,7 +207,6 @@ public function testExpiredPurchasedPlanWithChangedTimezone() {
$end_date->setTimezone($purchased_plan->getRatePlan()->getOrganization()->getTimezone());
$purchased_plan->setEndDate($end_date);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down Expand Up @@ -247,7 +242,6 @@ public function testFuturePurchasedPlanWithChangedTimezone() {
$start_date = new \DateTimeImmutable('today +2 day', new \DateTimeZone($this->orgDefaultTimezone));
$purchased_plan->setStartDate($start_date);

$this->warmOrganizationCache();
$this->stack
->queueMockResponse(['get_developer_purchased_plans' => ['purchased_plans' => [$purchased_plan]]]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function testPrepaidBalanceReportsDownloadForm() {
]);

$this->drupalLogin($this->account);
$this->warmOrganizationCache();
$this->queueDeveloperResponse($this->account);
$this->queueMockResponses([
'get-prepaid-balances',
Expand Down
2 changes: 1 addition & 1 deletion tests/src/Kernel/AutoAssignLegalNameKernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected function setUp(): void {
'system',
]);
$this->installEntitySchema('user');
$this->warmOrganizationCache();
$this->developer = $this->createAccount(['view rate_plan']);
$this->setCurrentUser($this->developer);

Expand All @@ -63,7 +64,6 @@ public function testAutoAssignLegalName() {
$subscription = $this->createPurchasedPlan($this->developer, $rate_plan);
$dev = $this->convertUserToEdgeDeveloper($this->developer, ['MINT_DEVELOPER_LEGAL_NAME' => $this->developer->getEmail()]);
\Drupal::cache('apigee_edge_entity')->delete("values:developer:{$dev->id()}");
$this->warmOrganizationCache();
$this->stack
->queueMockResponse([
'developer_mint' => ['developer' => $dev],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ public function testMyRedirects() {
* Tests the plan controller response.
*/
public function testControllerResponse() {
// Queue up a monetized org response.
$this->stack->queueMockResponse('get_monetized_org');
// Warm the cache for the monetized org check.
\Drupal::service('apigee_m10n.monetization')->isMonetizationEnabled();

Expand All @@ -149,7 +147,6 @@ public function testControllerResponse() {
* displayed on the page.
*/
public function testPlansFiltering() {
$this->warmOrganizationCache();

$rate_plans = [];
$product_bundles = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function setUp():void {
$this->installEntitySchema('user');
$this->accessControlHandler = $this->container->get('entity_type.manager')
->getAccessControlHandler('rate_plan');

$this->warmOrganizationCache();
// Create root user.
$this->createUser();

Expand Down
2 changes: 2 additions & 0 deletions tests/src/Traits/ApigeeMonetizationTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ protected function setUp(): void {
*/
protected function createAccount(array $permissions = [], bool $status = TRUE, string $prefix = '', $attributes = []): ?UserInterface {
$rid = NULL;
$this->warmOrganizationCache();
if ($permissions) {
$rid = $this->createRole($permissions);
$this->assertNotEmpty($rid, 'Role created');
Expand Down Expand Up @@ -233,6 +234,7 @@ protected function createProduct(): MonetizationApiProduct {
*/
protected function createProductBundle(): ProductBundleInterface {
$products = [];

for ($i = rand(1, 4); $i > 0; $i--) {
$products[] = $this->createProduct();
}
Expand Down

0 comments on commit 87a6478

Please sign in to comment.