EntityCitationRenderTest.php in Bibliography & Citation 8
File
modules/bibcite_entity/tests/src/Kernel/EntityCitationRenderTest.php
View source
<?php
namespace Drupal\Tests\bibcite_entity\Kernel;
use Drupal\bibcite_entity\Entity\Reference;
use Drupal\KernelTests\KernelTestBase;
use Symfony\Component\Yaml\Yaml;
class EntityCitationRenderTest extends KernelTestBase {
public static $modules = [
'system',
'user',
'serialization',
'bibcite',
'bibcite_entity',
];
protected $styler;
protected $serializer;
public function setUp() {
parent::setUp();
$this
->installConfig([
'user',
'bibcite',
'bibcite_entity',
]);
$this->styler = $this->container
->get('bibcite.citation_styler');
$this->serializer = $this->container
->get('serializer');
}
public function testEntityRender($entity_values, $expected) {
$entity = Reference::create($entity_values);
$data = $this->serializer
->normalize($entity, 'csl');
$citation = $this->styler
->render($data);
$this
->assertEquals($expected, strip_tags($citation));
}
public function providerReferenceEntity() {
$yaml_text = file_get_contents(__DIR__ . '/data/testEntityRender.data.yml');
return Yaml::parse($yaml_text);
}
}