1<?php 2/** 3 * @group plugin_latexport 4 * @group plugins 5 */ 6 7require_once DOKU_PLUGIN . 'latexport/_test/decorator_mock.php'; 8require_once DOKU_PLUGIN . 'latexport/implementation/decorator_images.php'; 9 10class DecoratorImagesTest extends DokuWikiTest { 11 12 protected $pluginsEnabled = array('latexport', 'mathjax'); 13 14 private $decoratorMock; 15 16 private $decoratorImages; 17 18 public static function setUpBeforeClass(){ 19 parent::setUpBeforeClass(); 20 } 21 22 public function setUp() { 23 $this->decoratorMock = new DecoratorMock(); 24 $this->decoratorImages = new DecoratorImages($this->decoratorMock); 25 } 26 27 public function testCanDisplayASingleImage() { 28 $this->decoratorImages->p_open(); 29 $this->decoratorImages->internalmedia("S1", "Title1", "centered", 10, 20); 30 $this->decoratorImages->p_close(); 31 32 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPOpen()); 33 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandInternalMedia("S1", "Title1", "centered", 10, 20, 0, 1)); 34 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPClose()); 35 36 $this->assertTrue($this->decoratorMock->noCommands(), "Should not have more commands"); 37 } 38 39 public function testCanDisplayTwoSingleImages() { 40 $this->decoratorImages->p_open(); 41 $this->decoratorImages->internalmedia("S1", "Title1", "centered", 10, 20); 42 $this->decoratorImages->cdata(" x "); 43 $this->decoratorImages->internalmedia("S2", "Title2", "22", 12, 22); 44 $this->decoratorImages->p_close(); 45 46 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPOpen()); 47 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandInternalMedia("S1", "Title1", "centered", 10, 20, 0, 1)); 48 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandCData(" x ")); 49 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandInternalMedia("S2", "Title2", "22", 12, 22, 0, 1)); 50 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPClose()); 51 52 $this->assertTrue($this->decoratorMock->noCommands(), "Should not have more commands"); 53 } 54 55 public function testCanGroupTwoImagesSeparatedWithASpace() { 56 $this->decoratorImages->p_open(); 57 $this->decoratorImages->internalmedia("S1", "Title1", "11", 11, 21); 58 $this->decoratorImages->cdata(" "); 59 $this->decoratorImages->internalmedia("S2", "Title2", "22", 12, 22); 60 $this->decoratorImages->p_close(); 61 62 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPOpen()); 63 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandCData(" ")); 64 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandInternalMedia("S1", "Title1", "11", 11, 21, 0, 2)); 65 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandInternalMedia("S2", "Title2", "22", 12, 22, 1, 2)); 66 $this->assertEquals($this->decoratorMock->nextCommand(), new CommandPClose()); 67 68 $this->assertTrue($this->decoratorMock->noCommands(), "Should not have more commands"); 69 } 70} 71?> 72