mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-03 23:07:32 -05:00 
			
		
		
		
	Fixes for scheduler
This commit is contained in:
		
							parent
							
								
									13a1447b79
								
							
						
					
					
						commit
						cf141e36c8
					
				@ -47,6 +47,9 @@ class GenericReportRequest extends Request
 | 
				
			|||||||
        if(!array_key_exists('report_keys', $input))
 | 
					        if(!array_key_exists('report_keys', $input))
 | 
				
			||||||
            $input['report_keys'] = [];
 | 
					            $input['report_keys'] = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!array_key_exists('send_email', $input))
 | 
				
			||||||
 | 
					            $input['send_email'] = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->replace($input);
 | 
					        $this->replace($input);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,13 +22,6 @@ trait RuntimeFormRequest
 | 
				
			|||||||
        $instance = $validator->getValidatorInstance();
 | 
					        $instance = $validator->getValidatorInstance();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $instance;
 | 
					        return $instance;
 | 
				
			||||||
        // if ($instance->fails()) {
 | 
					 | 
				
			||||||
        //     return $instance->errors();
 | 
					 | 
				
			||||||
        // }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // $validator->passedValidation();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // return $validator->all();
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -27,4 +27,14 @@ class CreateScheduledTaskRequest extends Request
 | 
				
			|||||||
            'job' => 'required',
 | 
					            'job' => 'required',
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function prepareForValidation()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $input = $this->all();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(!array_key_exists('start_from', $input))
 | 
				
			||||||
 | 
					            $input['start_from'] = now();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->replace($input);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -41,13 +41,13 @@ class UpdateScheduleRequest extends Request
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function prepareForValidation()
 | 
					    public function prepareForValidation()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $request = $this->all();
 | 
					        $input = $this->all();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (isset($request['start_from'])) {
 | 
					        if (isset($input['start_from'])) {
 | 
				
			||||||
            $request['scheduled_run'] = Carbon::parse((int)$request['start_from']);
 | 
					            $input['scheduled_run'] = Carbon::parse((int)$input['start_from']);
 | 
				
			||||||
            $request['start_from'] = Carbon::parse((int)$request['start_from']);
 | 
					            $input['start_from'] = Carbon::parse((int)$input['start_from']);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->replace($request);
 | 
					        $this->replace($input);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -90,98 +90,100 @@ class TaskSchedulerService
 | 
				
			|||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $rules = (new GenericReportRequest)->rules();
 | 
				
			||||||
                //custom rules for example here we require date_range but in genericRequest class we don't
 | 
					                //custom rules for example here we require date_range but in genericRequest class we don't
 | 
				
			||||||
                $rules['date_range'] = 'string|required';
 | 
					                $rules['date_range'] = 'string|required';
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					
 | 
				
			||||||
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_CLIENT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_CLIENT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(ClientExport::class);
 | 
					                $job->action_class = $this->getClassPath(ClientExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_CLIENT_CONTACT_REPORT:
 | 
					            case ScheduledJob::CREATE_CLIENT_CONTACT_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_CLIENT_CONTACT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_CLIENT_CONTACT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(ContactExport::class);
 | 
					                $job->action_class = $this->getClassPath(ContactExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_CREDIT_REPORT:
 | 
					            case ScheduledJob::CREATE_CREDIT_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_CREDIT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_CREDIT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(CreditExport::class);
 | 
					                $job->action_class = $this->getClassPath(CreditExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_DOCUMENT_REPORT:
 | 
					            case ScheduledJob::CREATE_DOCUMENT_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_DOCUMENT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_DOCUMENT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(DocumentExport::class);
 | 
					                $job->action_class = $this->getClassPath(DocumentExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_EXPENSE_REPORT:
 | 
					            case ScheduledJob::CREATE_EXPENSE_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_EXPENSE_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_EXPENSE_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(ExpenseExport::class);
 | 
					                $job->action_class = $this->getClassPath(ExpenseExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_INVOICE_ITEM_REPORT:
 | 
					            case ScheduledJob::CREATE_INVOICE_ITEM_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_INVOICE_ITEM_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_INVOICE_ITEM_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(InvoiceItemExport::class);
 | 
					                $job->action_class = $this->getClassPath(InvoiceItemExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_INVOICE_REPORT:
 | 
					            case ScheduledJob::CREATE_INVOICE_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_INVOICE_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_INVOICE_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(InvoiceExport::class);
 | 
					                $job->action_class = $this->getClassPath(InvoiceExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_PAYMENT_REPORT:
 | 
					            case ScheduledJob::CREATE_PAYMENT_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_PAYMENT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_PAYMENT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(PaymentExport::class);
 | 
					                $job->action_class = $this->getClassPath(PaymentExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_PRODUCT_REPORT:
 | 
					            case ScheduledJob::CREATE_PRODUCT_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_PRODUCT_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_PRODUCT_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(ProductExport::class);
 | 
					                $job->action_class = $this->getClassPath(ProductExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_PROFIT_AND_LOSS_REPORT:
 | 
					            case ScheduledJob::CREATE_PROFIT_AND_LOSS_REPORT:
 | 
				
			||||||
                $rules = (new ProfitLossRequest())->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_PROFIT_AND_LOSS_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_PROFIT_AND_LOSS_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(ProfitAndLoss::class);
 | 
					                $job->action_class = $this->getClassPath(ProfitAndLoss::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_QUOTE_ITEM_REPORT:
 | 
					            case ScheduledJob::CREATE_QUOTE_ITEM_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_QUOTE_ITEM_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_QUOTE_ITEM_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(QuoteItemExport::class);
 | 
					                $job->action_class = $this->getClassPath(QuoteItemExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_QUOTE_REPORT:
 | 
					            case ScheduledJob::CREATE_QUOTE_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_QUOTE_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_QUOTE_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(QuoteExport::class);
 | 
					                $job->action_class = $this->getClassPath(QuoteExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_RECURRING_INVOICE_REPORT:
 | 
					            case ScheduledJob::CREATE_RECURRING_INVOICE_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_RECURRING_INVOICE_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_RECURRING_INVOICE_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(RecurringInvoiceExport::class);
 | 
					                $job->action_class = $this->getClassPath(RecurringInvoiceExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            case ScheduledJob::CREATE_TASK_REPORT:
 | 
					            case ScheduledJob::CREATE_TASK_REPORT:
 | 
				
			||||||
                $rules = (new GenericReportRequest)->rules();
 | 
					                $validator = GenericReportRequest::runFormRequest($request->all());
 | 
				
			||||||
                $validatedJobData = $request->validate($rules);
 | 
					                $validatedJobData = $validator->validate();
 | 
				
			||||||
                $job->action_name = ScheduledJob::CREATE_TASK_REPORT;
 | 
					                $job->action_name = ScheduledJob::CREATE_TASK_REPORT;
 | 
				
			||||||
                $job->action_class = $this->getClassPath(TaskExport::class);
 | 
					                $job->action_class = $this->getClassPath(TaskExport::class);
 | 
				
			||||||
                $job->parameters = $validatedJobData;
 | 
					                $job->parameters = $validatedJobData;
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,7 @@ use Illuminate\Routing\Middleware\ThrottleRequests;
 | 
				
			|||||||
use Illuminate\Support\Facades\Session;
 | 
					use Illuminate\Support\Facades\Session;
 | 
				
			||||||
use Tests\MockUnitData;
 | 
					use Tests\MockUnitData;
 | 
				
			||||||
use Tests\TestCase;
 | 
					use Tests\TestCase;
 | 
				
			||||||
 | 
					use Illuminate\Validation\ValidationException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SchedulerTest extends TestCase
 | 
					class SchedulerTest extends TestCase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -35,10 +36,12 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $this->makeTestData();
 | 
					        $this->makeTestData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->withoutMiddleware(
 | 
					        $this->withoutMiddleware(
 | 
				
			||||||
            ThrottleRequests::class
 | 
					            ThrottleRequests::class
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // $this->withoutExceptionHandling();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function testSchedulerCantBeCreatedWithWrongData()
 | 
					    public function testSchedulerCantBeCreatedWithWrongData()
 | 
				
			||||||
@ -48,13 +51,23 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
            'job' => ScheduledJob::CREATE_CLIENT_REPORT,
 | 
					            'job' => ScheduledJob::CREATE_CLIENT_REPORT,
 | 
				
			||||||
            'date_key' => '123',
 | 
					            'date_key' => '123',
 | 
				
			||||||
            'report_keys' => ['test'],
 | 
					            'report_keys' => ['test'],
 | 
				
			||||||
            // 'date_range' => 'all',
 | 
					            'date_range' => 'all',
 | 
				
			||||||
 | 
					            // 'start_from' => '2022-01-01'
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $response = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // try {
 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
            'X-API-SECRET' => config('ninja.api_secret'),
 | 
					            'X-API-SECRET' => config('ninja.api_secret'),
 | 
				
			||||||
            'X-API-TOKEN' => $this->token,
 | 
					            'X-API-TOKEN' => $this->token,
 | 
				
			||||||
        ])->post('/api/v1/task_scheduler/', $data);
 | 
					        ])->post('/api/v1/task_scheduler/', $data);
 | 
				
			||||||
 | 
					    // } catch (ValidationException $e) {
 | 
				
			||||||
 | 
					    //              $message = json_decode($e->validator->getMessageBag(), 1);
 | 
				
			||||||
 | 
					    //              nlog($message);
 | 
				
			||||||
 | 
					    // }
 | 
				
			||||||
 | 
					            // $response->assertStatus(200);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $response->assertSessionHasErrors();
 | 
					        $response->assertSessionHasErrors();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -62,10 +75,14 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testSchedulerCanBeUpdated()
 | 
					    public function testSchedulerCanBeUpdated()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
       $this->createScheduler();
 | 
					        $response = $this->createScheduler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        nlog($response);
 | 
				
			||||||
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					        $id = $arr['data']['id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $scheduler = Scheduler::find($this->decodePrimaryKey($id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $scheduler = Scheduler::first();
 | 
					 | 
				
			||||||
        $updateData = [
 | 
					        $updateData = [
 | 
				
			||||||
            'start_from' => 1655934741
 | 
					            'start_from' => 1655934741
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
@ -80,10 +97,12 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testSchedulerCanBeSeen()
 | 
					    public function testSchedulerCanBeSeen()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->createScheduler();
 | 
					        $response = $this->createScheduler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					        $id = $arr['data']['id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $scheduler = Scheduler::first();
 | 
					        $scheduler = Scheduler::find($this->decodePrimaryKey($id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
            'X-API-SECRET' => config('ninja.api_secret'),
 | 
					            'X-API-SECRET' => config('ninja.api_secret'),
 | 
				
			||||||
@ -98,9 +117,13 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testSchedulerCanBeDeleted()
 | 
					    public function testSchedulerCanBeDeleted()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->createScheduler();
 | 
					        $response = $this->createScheduler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					        $id = $arr['data']['id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $scheduler = Scheduler::find($this->decodePrimaryKey($id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $scheduler = Scheduler::first();
 | 
					 | 
				
			||||||
        $response = $this->withHeaders([
 | 
					        $response = $this->withHeaders([
 | 
				
			||||||
            'X-API-SECRET' => config('ninja.api_secret'),
 | 
					            'X-API-SECRET' => config('ninja.api_secret'),
 | 
				
			||||||
            'X-API-TOKEN' => $this->token,
 | 
					            'X-API-TOKEN' => $this->token,
 | 
				
			||||||
@ -112,9 +135,13 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function testSchedulerJobCanBeUpdated()
 | 
					    public function testSchedulerJobCanBeUpdated()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->createScheduler();
 | 
					        $response = $this->createScheduler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					        $id = $arr['data']['id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $scheduler = Scheduler::find($this->decodePrimaryKey($id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $scheduler = Scheduler::first();
 | 
					 | 
				
			||||||
        $this->assertSame('create_client_report', $scheduler->job->action_name);
 | 
					        $this->assertSame('create_client_report', $scheduler->job->action_name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $updateData = [
 | 
					        $updateData = [
 | 
				
			||||||
@ -130,6 +157,7 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $updatedSchedulerJob = Scheduler::first()->job->action_name;
 | 
					        $updatedSchedulerJob = Scheduler::first()->job->action_name;
 | 
				
			||||||
        $arr = $response->json();
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->assertSame('create_credit_report', $arr['data']['job']['action_name']);
 | 
					        $this->assertSame('create_credit_report', $arr['data']['job']['action_name']);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -137,6 +165,11 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        $response = $this->createScheduler();
 | 
					        $response = $this->createScheduler();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $arr = $response->json();
 | 
				
			||||||
 | 
					        $id = $arr['data']['id'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $scheduler = Scheduler::find($this->decodePrimaryKey($id));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $all_schedulers = Scheduler::count();
 | 
					        $all_schedulers = Scheduler::count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->assertSame(1, $all_schedulers);
 | 
					        $this->assertSame(1, $all_schedulers);
 | 
				
			||||||
@ -153,6 +186,7 @@ class SchedulerTest extends TestCase
 | 
				
			|||||||
            'date_key' => '123',
 | 
					            'date_key' => '123',
 | 
				
			||||||
            'report_keys' => ['test'],
 | 
					            'report_keys' => ['test'],
 | 
				
			||||||
            'date_range' => 'all',
 | 
					            'date_range' => 'all',
 | 
				
			||||||
 | 
					            'start_from' => '2022-01-01'
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return $response = $this->withHeaders([
 | 
					        return $response = $this->withHeaders([
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user