Skip to content

Commit

Permalink
Rename tabPageName to tabName - removing references to 'page'
Browse files Browse the repository at this point in the history
  • Loading branch information
rob-baillie-ortoo committed Feb 7, 2022
1 parent 778c28b commit 329321c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
public virtual with sharing class AbstractRedirectToLwcTabController
{
protected String tabPageName;
protected String tabName;

/**
* States if the controller currently has records assigned to it
Expand Down Expand Up @@ -98,9 +98,9 @@ public virtual with sharing class AbstractRedirectToLwcTabController
*/
public PageReference redirectToTab()
{
Contract.requires( this.tabPageName != null, 'redirectToTab called with a null this.tabPageName. Ensure that the controller extension ('+ObjectUtils.getClassName( this )+') sets "this.tabPageName" in the constructor' );
Contract.requires( this.tabName != null, 'redirectToTab called with a null this.tabName. Ensure that the controller extension ('+ObjectUtils.getClassName( this )+') sets "this.tabName" in the constructor' );

PageReference appPage = new PageReference( '/lightning/n/' + this.tabPageName );
PageReference appPage = new PageReference( '/lightning/n/' + this.tabName );
appPage.getParameters().put( 'c__returnUrl', returnUrl );
appPage.getParameters().put( 'c__epoch', epochTime );
appPage.getParameters().put( 'c__recordIds', serializedRecordIds );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@isTest
public with sharing class AbstractRedirectToLwcTabControllerTest
public with sharing class AbstractRedirectToLwcTabControllerTest
{
@isTest
private static void hasRecords_whenRecordsAreSelected_returnsTrue() // NOPMD: Test method name format
Expand All @@ -12,7 +12,7 @@ public with sharing class AbstractRedirectToLwcTabControllerTest

ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
standardSetController.setSelected( context );
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
TestableRedirectToLwcTabController controller = new TestableRedirectToLwcTabController( standardSetController );

Test.startTest();
Boolean got = controller.hasRecords;
Expand All @@ -32,7 +32,7 @@ public with sharing class AbstractRedirectToLwcTabControllerTest

ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
standardSetController.setSelected( new List<Contact>() );
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
TestableRedirectToLwcTabController controller = new TestableRedirectToLwcTabController( standardSetController );

Test.startTest();
Boolean got = controller.hasRecords;
Expand All @@ -54,13 +54,13 @@ public with sharing class AbstractRedirectToLwcTabControllerTest

ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
standardSetController.setSelected( context );
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
TestableRedirectToLwcTabController controller = new TestableRedirectToLwcTabController( standardSetController );

Test.startTest();
PageReference got = controller.redirectToTab();
Test.stopTest();

Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTab, when called, will retrun a PageReference with the URL pointing to the defined tab page' );
Amoss_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when called, will retrun a PageReference with the URL pointing to the defined tab page' );

Map<String,String> parameters = got.getParameters();
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTab, when called, will return a PageReference with a return url parameter' );
Expand All @@ -81,26 +81,26 @@ public with sharing class AbstractRedirectToLwcTabControllerTest

ApexPages.StandardSetController standardSetController = new ApexPages.StandardSetController( context );
standardSetController.setSelected( new List<Contact>() );
TestableRedirectToLwcTabPageController controller = new TestableRedirectToLwcTabPageController( standardSetController );
TestableRedirectToLwcTabController controller = new TestableRedirectToLwcTabController( standardSetController );

Test.startTest();
PageReference got = controller.redirectToTab();
Test.stopTest();

Amoss_Asserts.assertContains( 'tabpagename', got.getUrl(), 'redirectToTab, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' );
Amoss_Asserts.assertContains( 'tabName', got.getUrl(), 'redirectToTab, when no records are selected, will retrun a PageReference with the URL pointing to the defined tab page' );

Map<String,String> parameters = got.getParameters();
System.assertEquals( 'testscenario', parameters.get( 'c__returnUrl' ), 'redirectToTab, when no records are selected, will return a PageReference with a return url parameter' );
System.assertNotEquals( null, parameters.get( 'c__epoch' ), 'redirectToTab, when no records are selected, will return a PageReference with an epoch parameter' );
System.assertEquals( expectedRecordIds, parameters.get( 'c__recordIds' ), 'redirectToTab, when no records are selected, will return a PageReference with a record ids parameter that contains a serialised empty list' );
}

class TestableRedirectToLwcTabPageController extends AbstractRedirectToLwcTabController
class TestableRedirectToLwcTabController extends AbstractRedirectToLwcTabController
{
public TestableRedirectToLwcTabPageController( ApexPages.StandardSetController controller )
public TestableRedirectToLwcTabController( ApexPages.StandardSetController controller )
{
super( controller );
this.tabPageName = 'tabpagename';
this.tabName = 'tabName';
}
}
}

0 comments on commit 329321c

Please sign in to comment.