create(); //Create the Process factory factory(Process::class)->create(); //Create the Dynaform factory factory(Dynaform::class)->create(); //Create the EmailServerModel factory factory(EmailServerModel::class)->create(); //Create the Application factory factory(Application::class)->create(); //Create the Delegation factory $delegation = factory(Delegation::class)->create(); //Create the AbeConfiguration factory $abeConfiguration = factory(AbeConfiguration::class)->create(); //Create the AbeConfiguration factory factory(AbeRequest::class)->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, 'ABE_REQ_UID' => $abeConfiguration->ABE_UID ]); //Call the getAbeRequest method $res = AbeConfiguration::getAbeRequest($abeConfiguration->ABE_UID); //Assert the result is not empty $this->assertNotEmpty($res); //Assert the result is the one looked for $this->assertEquals($res['ABE_UID'], $abeConfiguration->ABE_UID); } /** * Tests the getAbeRequest method when the result is empty * * @covers \ProcessMaker\Model\AbeConfiguration::getAbeRequest() * @test */ public function it_should_test_the_get_abe_request_method_when_the_result_is_empty() { //Creates the Task factory factory(Task::class)->create(); //Creates the Process factory factory(Process::class)->create(); //Creates the Dynaform factory factory(Dynaform::class)->create(); //Creates the EmailServer factory factory(EmailServerModel::class)->create(); //Creates the Application factory factory(Application::class)->create(); //Creates the Delegation factory $delegation = factory(Delegation::class)->create(); //Creates the AbeConfiguration factory $abeConfiguration = factory(AbeConfiguration::class)->create(); //Creates the AbeConfiguration factory factory(AbeRequest::class)->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, 'ABE_REQ_UID' => $abeConfiguration->ABE_UID ]); //Call the getAbeRequest method $res = AbeConfiguration::getAbeRequest(''); //Asserts the result has one record $this->assertEmpty($res); } /** * It should test the updateReceiverUidToEmpty method * * @covers \ProcessMaker\Model\AbeConfiguration::updateReceiverUidToEmpty() * @test */ public function it_should_test_the_update_abe_configuration_receiver_uid_method() { $emailServer = factory(EmailServerModel::class)->create(); $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); $abeConfiguration = new AbeConfiguration(); $abeConfiguration->updateReceiverUidToEmpty($emailServer['MESS_UID']); $query = AbeConfiguration::query()->select(); $query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']); $updatedAbe = $query->get()->values()->toArray(); $this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_RECEIVER_UID'], ''); } /** * It should test the updateEmailServerUidToDefaultOrEmpty method when there is not a default server * * @covers \ProcessMaker\Model\AbeConfiguration::updateEmailServerUidToDefaultOrEmpty() * @test */ public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_not_a_default_server() { EmailServerModel::query()->delete(); $emailServer = factory(EmailServerModel::class)->create(); $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); $abeConfiguration = new AbeConfiguration(); $abeConfiguration->updateEmailServerUidToDefaultOrEmpty($emailServer['MESS_UID']); $query = AbeConfiguration::query()->select(); $query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']); $updatedAbe = $query->get()->values()->toArray(); $this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_UID'], ''); } /** * It should test the updateEmailServerUidToDefaultOrEmpty method when there is a default server * * @covers \ProcessMaker\Model\AbeConfiguration::updateEmailServerUidToDefaultOrEmpty() * @test */ public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_a_default_server() { EmailServerModel::query()->delete(); $emailServer = factory(EmailServerModel::class)->create(); $defaultServer = factory(EmailServerModel::class)->create([ 'MESS_DEFAULT' => 1 ]); $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); $abeConfiguration = new AbeConfiguration(); $abeConfiguration->updateEmailServerUidToDefaultOrEmpty($emailServer['MESS_UID']); $query = AbeConfiguration::query()->select(); $query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']); $updatedAbe = $query->get()->values()->toArray(); $this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_UID'], $defaultServer['MESS_UID']); } }