-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Hide the open in new window checkbox from phone and email links #187
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,12 +25,12 @@ class AllowedLinkClassesTraitTest extends SapphireTest | |
* Need to include only known Link subclasses. | ||
*/ | ||
private $link_types = [ | ||
SiteTreeLink::class, | ||
ExternalLink::class, | ||
FileLink::class, | ||
EmailLink::class, | ||
PhoneLink::class, | ||
TestPhoneLink::class, | ||
'sitetree' => SiteTreeLink::class, | ||
'external' => ExternalLink::class, | ||
'file' => FileLink::class, | ||
'email' => EmailLink::class, | ||
'phone' => PhoneLink::class, | ||
'testphone' => TestPhoneLink::class, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated refactoring to make it easier to run unit tests locally when you have a custom link type in your project |
||
]; | ||
|
||
public function setUp(): void | ||
|
@@ -58,20 +58,20 @@ public function allowedTypesDataProvider() : array | |
return [ | ||
'allow all Link classes' => [ | ||
'enabled' => [ | ||
SiteTreeLink::class, | ||
ExternalLink::class, | ||
FileLink::class, | ||
EmailLink::class, | ||
PhoneLink::class, | ||
TestPhoneLink::class, | ||
SiteTreeLink::class, | ||
ExternalLink::class, | ||
FileLink::class, | ||
EmailLink::class, | ||
PhoneLink::class, | ||
TestPhoneLink::class, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated refactoring |
||
], | ||
'expected' => [ | ||
SiteTreeLink::class, | ||
ExternalLink::class, | ||
FileLink::class, | ||
EmailLink::class, | ||
PhoneLink::class, | ||
TestPhoneLink::class, | ||
SiteTreeLink::class, | ||
ExternalLink::class, | ||
FileLink::class, | ||
EmailLink::class, | ||
PhoneLink::class, | ||
TestPhoneLink::class, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated refactoring |
||
], | ||
], | ||
'allow only SiteTreeLink class' => [ | ||
|
@@ -174,10 +174,11 @@ public function testGetSortedTypeProps(array $enabled, array $expected, bool $re | |
if ($reorder) { | ||
Injector::inst()->get(TestPhoneLink::class)->config()->set('menu_priority', 5); | ||
} | ||
|
||
$linkField = LinkField::create('LinkField'); | ||
$linkField->setAllowedTypes($enabled); | ||
$json = json_decode($linkField->getTypesProps(), true); | ||
$json = $this->removeCustomLinkTypes($json); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is unrelated refactoring to make it easier to run unit tests locally when you have a custom link type in your project |
||
$this->assertEquals(array_keys($json), $expected); | ||
} | ||
|
||
|
@@ -277,4 +278,18 @@ public function testGetTypesProps( | |
$this->assertEquals($icon, $json[$key]['icon']); | ||
$this->assertEquals($allowed, $json[$key]['allowed']); | ||
} | ||
|
||
/** | ||
* Remove any classes defined at the project level that interfere with running unit-tests locally | ||
*/ | ||
private function removeCustomLinkTypes(array $json): array | ||
{ | ||
$newJson = []; | ||
foreach ($json as $key => $value) { | ||
if (array_key_exists($key, $this->link_types)) { | ||
$newJson[$key] = $value; | ||
} | ||
} | ||
return $newJson; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated refactoring