From ec6de361053cb9881c0e05bcc2da5b23bcc0b7e2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 18 Jan 2023 21:07:15 +1100 Subject: [PATCH] Fixes for tests --- .../Feature/Account/AccountEmailQuotaTest.php | 98 ++++++++++--------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/tests/Feature/Account/AccountEmailQuotaTest.php b/tests/Feature/Account/AccountEmailQuotaTest.php index c7d39f92cac3..408a33754c95 100644 --- a/tests/Feature/Account/AccountEmailQuotaTest.php +++ b/tests/Feature/Account/AccountEmailQuotaTest.php @@ -30,55 +30,8 @@ class AccountEmailQuotaTest extends TestCase parent::setUp(); } - public function testQuotaValidRule() - { - $account = Account::factory()->create([ - 'hosted_client_count' => 1000, - 'hosted_company_count' => 1000, - 'is_flagged' => false, - 'key' => '123ifyouknowwhatimean', - 'created_at' => now(), - 'updated_at' => now(), - ]); - - $account->num_users = 3; - $account->save(); - - Cache::increment($account->key); - - $this->assertFalse($account->emailQuotaExceeded()); - - Cache::forget('123ifyouknowwhatimean'); - - } - - public function testEmailSentCount() - { - $account = Account::factory()->create([ - 'hosted_client_count' => 1000, - 'hosted_company_count' => 1000, - 'is_flagged' => false, - 'key' => '123ifyouknowwhatimean', - 'created_at' => now(), - 'updated_at' => now(), - ]); - - $account->num_users = 3; - $account->save(); - - - Cache::put($account->key, 3000); - - $count = $account->emailsSent(); - - $this->assertEquals(3000, $count); - - Cache::forget('123ifyouknowwhatimean'); - - } - - public function testQuotaInValidRule() + public function testIfQuotaBreached() { config([ @@ -141,4 +94,53 @@ class AccountEmailQuotaTest extends TestCase Cache::forget('123ifyouknowwhatimean'); } + + public function testQuotaValidRule() + { + + $account = Account::factory()->create([ + 'hosted_client_count' => 1000, + 'hosted_company_count' => 1000, + 'is_flagged' => false, + 'key' => '123ifyouknowwhatimean', + 'created_at' => now(), + 'updated_at' => now(), + ]); + + $account->num_users = 3; + $account->save(); + + Cache::increment($account->key); + + $this->assertFalse($account->emailQuotaExceeded()); + + Cache::forget('123ifyouknowwhatimean'); + + } + + public function testEmailSentCount() + { + $account = Account::factory()->create([ + 'hosted_client_count' => 1000, + 'hosted_company_count' => 1000, + 'is_flagged' => false, + 'key' => '123ifyouknowwhatimean', + 'created_at' => now(), + 'updated_at' => now(), + ]); + + $account->num_users = 3; + $account->save(); + + + Cache::put($account->key, 3000); + + $count = $account->emailsSent(); + + $this->assertEquals(3000, $count); + + Cache::forget('123ifyouknowwhatimean'); + + } + }