function UrlHelperTest::testCompressUncompress

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php \Drupal\Tests\Component\Utility\UrlHelperTest::testCompressUncompress()

Tests that we get the same thing out that we put in.

File

core/tests/Drupal/Tests/Component/Utility/UrlHelperTest.php, line 115

Class

UrlHelperTest
@group Utility

Namespace

Drupal\Tests\Component\Utility

Code

public function testCompressUncompress() : void {
    $data = [];
    while (count($data) < 30) {
        $data[] = 'drupal/drupal' . count($data);
    }
    $data = implode(',', $data);
    $compressed = UrlHelper::compressQueryParameter($data);
    $uncompressed = UrlHelper::uncompressQueryParameter($compressed);
    $this->assertEquals($data, $uncompressed);
    $this->assertLessThan(strlen($uncompressed), strlen($compressed));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.