|
|
|
@ -264,4 +264,36 @@ class StringHelperTest extends TestCase
|
|
|
|
|
$this->assertEquals(1, StringHelper::countWords('крем-брюле')); |
|
|
|
|
$this->assertEquals(1, StringHelper::countWords(' слово ')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @dataProvider base64UrlEncodedStringsProvider |
|
|
|
|
* @param $input |
|
|
|
|
* @param $base64UrlEncoded |
|
|
|
|
*/ |
|
|
|
|
public function testBase64UrlEncode($input, $base64UrlEncoded) |
|
|
|
|
{ |
|
|
|
|
$encoded = StringHelper::base64UrlEncode($input); |
|
|
|
|
$this->assertEquals($base64UrlEncoded, $encoded); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @dataProvider base64UrlEncodedStringsProvider |
|
|
|
|
* @param $output |
|
|
|
|
* @param $base64UrlEncoded |
|
|
|
|
*/ |
|
|
|
|
public function testBase64UrlDecode($output, $base64UrlEncoded) |
|
|
|
|
{ |
|
|
|
|
$decoded = StringHelper::base64UrlDecode($base64UrlEncoded); |
|
|
|
|
$this->assertEquals($output, $decoded); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function base64UrlEncodedStringsProvider() |
|
|
|
|
{ |
|
|
|
|
return [ |
|
|
|
|
['This is an encoded string', 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw=='], |
|
|
|
|
['subjects?_d=1', 'c3ViamVjdHM_X2Q9MQ=='], |
|
|
|
|
['subjects>_d=1', 'c3ViamVjdHM-X2Q9MQ=='], |
|
|
|
|
['Это закодированная строка', '0K3RgtC-INC30LDQutC-0LTQuNGA0L7QstCw0L3QvdCw0Y8g0YHRgtGA0L7QutCw'], |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|