You are here

RisDecodeTest.php in Bibliography & Citation 2.0.x

Same filename and directory in other branches
  1. 8 modules/bibcite_ris/tests/src/Kernel/RisDecodeTest.php

File

modules/bibcite_ris/tests/src/Kernel/RisDecodeTest.php
View source
<?php

namespace Drupal\Tests\bibcite_ris\Kernel;

use Drupal\bibcite_ris\Encoder\RISEncoder;
use Drupal\Tests\bibcite_import\Kernel\FormatDecoderTestBase;

/**
 * @coversDefaultClass \Drupal\bibcite_ris\Encoder\RISEncoder
 * @group bibcite
 */
class RisDecodeTest extends FormatDecoderTestBase {

  /**
   * Modules to install.
   *
   * @var array
   */
  public static $modules = [
    'system',
    'user',
    'serialization',
    'bibcite',
    'bibcite_entity',
    'bibcite_ris',
  ];

  /**
   * {@inheritdoc}
   */
  public function setUp() {
    parent::setUp();
    $this
      ->installConfig([
      'system',
      'user',
      'serialization',
      'bibcite',
      'bibcite_entity',
      'bibcite_ris',
    ]);
    $this->encoder = new RISEncoder();
    $this->format = 'ris';
    $this->resultDir = __DIR__ . '/../../data/decoded';
    $this->inputDir = __DIR__ . '/../../data/encoded';
  }

  /**
   * Tests a pages decode.
   *
   * @coversDefaultClass
   */
  public function testPagesDecode() {
    $data = "TY - SER\nTI - test\nSP - 1\nEP - 3\nSP - 7\nEP - 9\nEP - 12\nSP - 19\nER - \n";
    $pages = '1-3, 7-9, 12, 19+';
    $example = [
      0 => [
        'TY' => 'SER',
        'TI' => 'test',
        'SP' => $pages,
        'EP' => $pages,
      ],
    ];
    $encoder = new RISEncoder();
    $result = $encoder
      ->decode($data, 'ris');
    $this
      ->assertEquals($example, $result);
  }

}

Classes

Namesort descending Description
RisDecodeTest @coversDefaultClass \Drupal\bibcite_ris\Encoder\RISEncoder @group bibcite