You are here

public function UrlDataTest::testEncodeDecode in Commerce Core 8.2

::covers encode ::covers decode.

File

tests/src/Unit/UrlDataTest.php, line 18

Class

UrlDataTest
@coversDefaultClass \Drupal\commerce\UrlData @group commerce

Namespace

Drupal\Tests\commerce\Unit

Code

public function testEncodeDecode() {
  $data = [
    'commerce_product',
    '1',
  ];
  $encoded_data = UrlData::encode($data);
  $this
    ->assertIsString($encoded_data);
  $decoded_data = UrlData::decode($encoded_data);
  $this
    ->assertIsArray($decoded_data);
  $this
    ->assertSame($data, $decoded_data);
  $invalid_data = UrlData::decode('INVALID');
  $this
    ->assertFalse($invalid_data);
}