Skip to content
Snippets Groups Projects
Commit 73ed3bd8 authored by Laurent's avatar Laurent
Browse files

hotline #95686 try to fix failing test on CI

parent 470a52ea
3 merge requests!3297WIP: Master,!3266Hotline,!3255Hotline#95686 xslt saut de ligne non effectif quand malle
Pipeline #8344 failed with stage
in 30 minutes and 10 seconds
......@@ -87,8 +87,14 @@ class Class_Notice_Xsl {
if(!$marc = $this->_record->getUnimarc())
return '';
return $this->filePutMarcToXML($marc);
}
public function filePutMarcToXML($marc) {
return ($marc_xml_array = static::getYaz()->marcToMarcXml($marc))
? static::getYaz()->writeMarcXmlInFile(implode("\n",$marc_xml_array))
? static::getYaz()->writeMarcXmlInFile(implode("\n", $marc_xml_array))
: '';
}
......
......@@ -75,17 +75,12 @@ class XslRechercheControllerViewnoticeWithInspectorGadgetAndMarcXMLEnabledTest e
class XslRechercheControllerViewnoticeAndMarcXMLWithLineBreaksTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
class XslRechercheControllerViewnoticeAndMarcXMLWithLineBreaksTest extends ModelTestCase {
protected
$_written_content;
/** @test */
public function writtenXmlShouldKeepNewLines() {
$profile = Class_Profil::getCurrentProfil();
$profile->setCfgModulesPreferences(['xslt' => '/tests/scenarios/Xsl/break_line.xsl'],
'recherche',
'viewnotice',
Class_TypeDoc::PERIODIQUE);
$profile->save();
$marcxml_output = [
" <subfield code=\"a\">Détail du contenu :",
" 1 pochette contenant des instruments pour enfant",
......@@ -93,33 +88,23 @@ class XslRechercheControllerViewnoticeAndMarcXMLWithLineBreaksTest extends Abstr
" 1 flûte à bec",
" </subfield>"
];
$cmd = $this->mock()
->whenCalled('exec')
->answers(true)
->whenCalled('getOutput')
->answers($marcxml_output);
$filesystem = $this->mock()
->whenCalled('unlink')
->answers(true)
$yaz = $this->mock()
->whenCalled('marcToMarcXml')
->with('marc content')
->answers($marcxml_output)
->whenCalled('file_put_contents')
->willDo(function($filename,$content) use ($marcxml_output)
{
if (FALSE === strpos($filename,'.xml'))
return;
$this->assertEquals($marcxml_output, explode("\n",$content),$content);
});
Class_Testing_Yaz::setCommand($cmd);
Class_Testing_Yaz::setFileSystem($filesystem);
->whenCalled('writeMarcXmlInFile')
->willDo(function($marcxml)
{
$this->_written_content = $marcxml;
});
$this->fixture('Class_Notice',
['id' => 2,
'type_doc' => Class_TypeDoc::PERIODIQUE,
'unimarc' => file_get_contents('tests/scenarios/Xsl/notice_onde.txt')]);
$this->dispatch('/opac/noticeajax/detail/id_notice/2', true);
$xsl = new Class_Notice_Xsl(new Class_Notice(), new Class_Profil());
$xsl->setYaz($yaz);
$xsl->filePutMarcToXML('marc content');
$this->assertTrue($filesystem->methodHasBeenCalled('file_put_contents'));
$this->assertEquals($marcxml_output, explode("\n", $this->_written_content));
}
}
......@@ -162,10 +147,11 @@ class XslDocTypeConfigurationPostDispatchTest extends Admin_AbstractControllerTe
}
abstract class XslNoticeajaxDetailTestCase extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Storm_Cache::beVolatile();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment