function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neil Wingate 7Neil Wingate 7 

Been a while.....help.... we have a VF Component put together from some scraps, but need to write test code, and coverage percent is failing.

Here is VF Component..
 
<apex:page standardcontroller="Account" extensions="accountSatController">
<apex:form >
<html lang="en">
<head>
  <meta charset="utf-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <title>jQuery UI Accordion - Collapse content</title>
  <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $( "#accordion" ).accordion({
      collapsible: true,active: false
    });
  } );
  </script>
</head>
<body>
<div id="accordion">
<apex:repeat value="{!satellite}" var="sat">
<h3><apex:outputLink value="/{!sat.id}" target="_parent">Right Click/Open To View -- {!sat.name}</apex:outputlink></h3>
<div><apex:outputLink value="/{!sat.id}" target="_parent">View Record</apex:outputlink><br/>
      {!sat.BillingStreet}, {!sat.BillingCity}, {!sat.BillingState}, {!sat.BillingPostalCode}, Phone: {!sat.Phone}, Fax: {!sat.Fax}<br/><br/>
</div>
</apex:repeat>
</div>
</body>
</html>
</apex:form>
</apex:page>

Here is Controller...
 
public with sharing class accountSatController {
    
    public accountSatController () {
    }
    
    public accountSatController(ApexPages.StandardController controller) {
    	ParentAccount = (Account)controller.getRecord(); 
    	satellite = [SELECT Id, Name, Phone, Fax,  BillingCity, BillingStreet, BillingState, BillingPostalCode, ParentId, Parent.Name FROM Account WHERE ParentId = :ParentAccount.Id OR Id = :ParentAccount.Id ORDER BY ParentId asc];
    }
    
    public List<Account> satellite{get;set;}
    public Account ParentAccount;
}

Here is my lame test class... bit of a mess, creating four accounts, with one being the Parent of all three... and then calling the VF component to display on an account page (the page of any of the four previously created)
 
@isTest
public class accountSatContr_Test {

    public static testMethod void myUnitTest() {
    	
		//Instantiate a new controller with all parameters in the page
        PageReference pageRef = Page.AccountSatellites;
        Test.setCurrentPage(pageRef);
        
        List<Account> satellite = new List<Account>();
    	
        Id BusinessRTId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Business').getRecordTypeId();
    
        List<Account> accountTree = new List<Account>();
        
        account a = new account (
        name = 'TestBusinessNamea',
        RecordTypeId = BusinessRTId,
        Phone = '4525251254'
        );
        insert a;
        
        account b = new account (
        name = 'TestBusinessNameb',
        RecordTypeId = BusinessRTId,
        Phone = '4525251254',
        ParentId = a.id
        );
        accountTree.add(b);
        account c = new account (
        name = 'TestBusinessNamec',
        RecordTypeId = BusinessRTId,
        Phone = '4525251254',
        ParentId = a.id
        );
        accountTree.add(c);
        account d = new account (
        name = 'TestBusinessNamed',
        RecordTypeId = BusinessRTId,
        Phone = '4525251254',
        ParentId = a.id
        );
        accountTree.add(d);
        
        insert accountTree;
		
        accountSatController controller = new accountSatController();
        controller.ParentAccount = a;
        //controller.satellite;// = [SELECT Id, Name, Phone, Fax,  BillingCity, BillingStreet, BillingState, BillingPostalCode, ParentId, Parent.Name FROM Account
                   //WHERE ParentId = :ParentAccount.Id OR Id = :ParentAccount.Id ORDER BY ParentId asc];
        System.debug(satellite.size());
		//System.assert(satellite.size()==4);
		
        //page.setRedirect(true);
        //return pageRef;
        
           	
        // TO DO: implement unit test
        
    }
}