Skip to content
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

FIX Get array values, not keys #11414

Merged

Conversation

GuySartorelli
Copy link
Member

We want the values, not the keys. We're just converting a potential associative array to an indexed one.
Should be done on get not set in case associative array values are set in the config, too.

Issue

Comment on lines +93 to +110
public function testAllowedProtocols(): void
{
$field = new UrlField('MyUrl');
// Defaults should be http and https
$this->assertSame(['https', 'http'], $field->getAllowedProtocols());

// Defaults change with config, and ignore keys
UrlField::config()->set('default_protocols', ['my-key' => 'ftp']);
$this->assertSame(['ftp'], $field->getAllowedProtocols());

// Can set explicit protocols - again keys are ignored
$field->setAllowedProtocols(['http', 'key' => 'irc', 'nntp']);
$this->assertSame(['http', 'irc', 'nntp'], $field->getAllowedProtocols());

// Can reset back to config defaults
$field->setAllowedProtocols([]);
$this->assertSame(['ftp'], $field->getAllowedProtocols());
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't use a dataprovider here, these need to happen sequentially.

@emteknetnz emteknetnz merged commit 33929e2 into silverstripe:6 Oct 2, 2024
11 checks passed
@emteknetnz emteknetnz deleted the pulls/6/values-not-leys branch October 2, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants