Here is my class
public class CombineContractAgreement {
Id LegalEntityId;
public CombineContractAgreement(ApexPages.StandardController controller){
LegalEntityId = ((SB_Legal_Entity__c)controller.getRecord()).Id;
}
public List<APXT_Redlining__Contract_Agreement__c>GetAllRelatedAgreement()
{
List <APXT_Redlining__Contract_Agreement__c> AllRelatedAgreements;
AllRelatedAgreements = [SELECT Name, Agreement_Type__C, APXT_Redlining__Status__c, APXT_Redlining__Effective_Date__c,
Agreement_Name__c FROM APXT_Redlining__Contract_Agreement__c WHERE Customer_Legal_Entity__c = :LegalEntityId OR Customer_Legal_Entity_2__c = :LegalEntityId OR
Customer_Legal_Entity_3__c = :LegalEntityId OR Party_4__c = :LegalEntityId OR Party_5__c = :LegalEntityId];
return AllRelatedAgreements;
}
}
Visualforce
<apex:page StandardController="SB_Legal_Entity__c" extensions="CombineContractAgreement" lightningStylesheets="true">
<apex:pageBlock title="All Related Agreements">
<apex:pageBlockTable value="{!AllRelatedAgreement}" var="item">
<apex:column >
<apex:outputLink value="https://hyclonehorizon--sb1.lightning.force.com/{!item.ID}">{!item.Name}</apex:outputLink>
</apex:column>
<apex:column value="{!item.Agreement_Name__c}" />
<apex:column value="{!item.Agreement_Type__c}" />
<apex:column value="{!item.APXT_Redlining__Status__c}" />
<apex:column value="{!item.APXT_Redlining__Effective_Date__c}" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>
Test Class
Result:@isTest
public class CombineContractAgreementTest {
static testMethod void testMethod1(){
//Create required legal alias for Legal Entitiy Object
Legal_Alias__c ali = new Legal_Alias__c();
ali.Name = 'NameLegalAlias';
system.debug('The Legal Alias name is '+ali.Name);
insert ali;
//Create Legal Entity
SB_Legal_Entity__c testEntity = new SB_Legal_Entity__c();
testEntity.Legal_Alias__c = ali.Id;
testEntity.Name = 'testLegalEntity';
insert testEntity;
//Create Contract Agreement
APXT_Redlining__Contract_Agreement__c testAgreement = new APXT_Redlining__Contract_Agreement__c();
testAgreement.Customer_Legal_Entity__c = testEntity.id;
testAgreement.APXT_Redlining__Status__c = 'inactive';
testAgreement.APXT_Redlining__Effective_Date__c = date.today();
testagreement.Agreement_Name__c = 'TestAgreement';
insert testAgreement;
System.debug('The Contract Agreements Legal Entity is' + testAgreement.Customer_Legal_Entity__c);
Test.StartTest();
//current page equal the legal entity page
ApexPages.StandardController stdctrl = new ApexPages.StandardController(testEntity);
ApexPages.currentPage().getParameters().put('id',testEntity.Id);
CombineContractAgreement testCombineAgree = new CombineContractAgreement(stdctrl);
stdctrl.cancel();
Test.Stoptest();
}
}

invoke the method against the page
Test.StartTest();
//current page equal the legal entity page
ApexPages.StandardController stdctrl = new ApexPages.StandardController( testEntity );
ApexPages.currentPage().getParameters().put('id',testEntity.Id);
CombineContractAgreement testCombineAgree = new CombineContractAgreement( stdctrl );
stdctrl.cancel();
List<APXT_Redlining__Contract_Agreement__c> someList = testCombineAgree.GetAllRelatedAgreement();
Test.Stoptest();