From f483ffabde13dd4d1f311a4798dce53a38d5fe1d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 18 Mar 2023 20:18:11 +1100 Subject: [PATCH] Add tests for scheduling email entity --- .../Feature/Scheduler/ScheduleEntityTest.php | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 tests/Feature/Scheduler/ScheduleEntityTest.php diff --git a/tests/Feature/Scheduler/ScheduleEntityTest.php b/tests/Feature/Scheduler/ScheduleEntityTest.php new file mode 100644 index 000000000000..76a4ddb02522 --- /dev/null +++ b/tests/Feature/Scheduler/ScheduleEntityTest.php @@ -0,0 +1,128 @@ +faker = \Faker\Factory::create(); + + Model::reguard(); + + $this->makeTestData(); + + $this->withoutMiddleware( + ThrottleRequests::class + ); + } + + public function testSchedulerStore() + { + + $data = [ + 'name' => 'A test entity email scheduler', + 'frequency_id' => RecurringInvoice::FREQUENCY_MONTHLY, + 'next_run' => now()->format('Y-m-d'), + 'template' => 'schedule_entity', + 'parameters' => [ + 'entity' => 'invoice', + 'entity_id' => $this->invoice->hashed_id, + ], + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); + + $response->assertStatus(200); + + } + + + public function testSchedulerStore2() + { + + $data = [ + 'name' => 'A test entity email scheduler', + 'frequency_id' => 0, + 'next_run' => now()->format('Y-m-d'), + 'template' => 'schedule_entity', + 'parameters' => [ + 'entity' => 'invoice', + 'entity_id' => $this->invoice->hashed_id, + ], + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); + + $response->assertStatus(200); + + } + + public function testSchedulerStore4() + { + + $data = [ + 'name' => 'A test entity email scheduler', + 'next_run' => now()->format('Y-m-d'), + 'template' => 'schedule_entity', + 'parameters' => [ + 'entity' => 'invoice', + 'entity_id' => $this->invoice->hashed_id, + ], + ]; + + $response = $this->withHeaders([ + 'X-API-SECRET' => config('ninja.api_secret'), + 'X-API-TOKEN' => $this->token, + ])->postJson('/api/v1/task_schedulers', $data); + + $response->assertStatus(200); + + } + + +} \ No newline at end of file