summaryrefslogtreecommitdiffstats
path: root/tests/Plugin/ConditionalFormatFixerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Plugin/ConditionalFormatFixerTest.php')
-rw-r--r--tests/Plugin/ConditionalFormatFixerTest.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/Plugin/ConditionalFormatFixerTest.php b/tests/Plugin/ConditionalFormatFixerTest.php
new file mode 100644
index 0000000..e0d97ac
--- /dev/null
+++ b/tests/Plugin/ConditionalFormatFixerTest.php
@@ -0,0 +1,44 @@
+<?php
+
+
+namespace PHPExcel\StyleFixer\Plugin;
+
+
+class ConditionalFormatFixerTest extends BasePluginTest
+{
+ public function test_execute()
+ {
+ $output = $this->getMock('\ZipArchive');
+ $template = $this->getMock('\ZipArchive');
+ $bookUtil = $this->createBookUtil(2, ['Sheet1' => 'xl/worksheets/sheet1.xml', 'Sheet2' => 'xl/worksheets/sheet2.xml']);
+
+ $output
+ ->expects($this->exactly(2))
+ ->method('getFromName')
+ ->with($this->logicalOr('xl/worksheets/sheet1.xml', 'xl/worksheets/sheet2.xml'))
+ ->will($this->returnCallback([$this, 'getOutputXml']))
+ ;
+ $template
+ ->expects($this->once())
+ ->method('getFromName')
+ ->with($this->equalTo('xl/worksheets/sheet2.xml'))
+ ->will($this->returnCallback([$this, 'getTemplateXml']))
+ ;
+ $output
+ ->expects($this->once())
+ ->method('addFromString')
+ ->with($this->equalTo('xl/worksheets/sheet2.xml'), $this->callback([$this, 'assertXmlHasExpectedContent']))
+ ;
+
+ $fixer = new ConditionalFormatFixer($bookUtil);
+ $fixer->execute($output, $template);
+ }
+
+ public function assertXmlHasExpectedContent($xml)
+ {
+ $this->assertContains('<conditionalFormatting><font/></conditionalFormatting>', $xml);
+ $this->assertNotContains('<conditionalFormatting/>', $xml);
+
+ return true;
+ }
+}