You are here

public function RisEncodeTest::testPagesEncode in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_ris/tests/src/Kernel/RisEncodeTest.php \Drupal\Tests\bibcite_ris\Kernel\RisEncodeTest::testPagesEncode()

Tests a pages encode.

@coversDefaultClass

File

modules/bibcite_ris/tests/src/Kernel/RisEncodeTest.php, line 55

Class

RisEncodeTest
@coversDefaultClass \Drupal\bibcite_ris\Encoder\RISEncoder @group bibcite

Namespace

Drupal\Tests\bibcite_ris\Kernel

Code

public function testPagesEncode() {
  $example = "TY - SER\nSP - 1\nEP - 3\nSP - 7\nEP - 9\nEP - 12\nSP - 19\nER - \n";
  $pages = '1-3,7-9,12,19+';
  $data = [
    0 => [
      'TY' => 'SER',
      'SP' => $pages,
    ],
  ];
  $encoder = new RISEncoder();
  $result = $encoder
    ->encode($data, 'ris');
  $this
    ->assertEquals($example, $result);
}