public function UrlEncodeTest::testRawUrlEncodeString in Tamper 8
Tests url encoding using the 'raw' method.
The raw method uses the PHP function rawurlencode().
The following cases are tested:
- encoding symbols;
- encoding a string with spaces;
- encoding special characters.
File
- tests/
src/ Unit/ Plugin/ Tamper/ UrlEncodeTest.php, line 79
Class
- UrlEncodeTest
- Tests the url encode plugin.
Namespace
Drupal\Tests\tamper\Unit\Plugin\TamperCode
public function testRawUrlEncodeString() {
$config = [
UrlEncode::SETTING_METHOD => 'rawurlencode',
];
$plugin = new UrlEncode($config, 'url_encode', [], $this
->getMockSourceDefinition());
$this
->assertEquals('%24%20%26%20%3C%20%3E%20%3F%20%3B%20%23%20%3A%20%3D%20%2C%20%22%20%27%20~%20%2B%20%25', $plugin
->tamper('$ & < > ? ; # : = , " \' ~ + %'));
$this
->assertEquals('String%20with%20spaces', $plugin
->tamper('String with spaces'));
$this
->assertEquals('special%20chars%3A%20%26%25%2A', $plugin
->tamper('special chars: &%*'));
}