public function testAddStyle() { $styler = new Styler(); $initialXml = $styler->getStyleSheetXml(); $styler->addStyle(new Style()); $this->assertEquals($initialXml, $styler->getStyleSheetXml()); $style = new Style(); $styler->addStyle($style->setFontBold()); $oneNewStyleXml = $styler->getStyleSheetXml(); $this->assertNotEquals($initialXml, $oneNewStyleXml); $styler->addStyle($style->setFontBold()); $this->assertEquals($oneNewStyleXml, $styler->getStyleSheetXml()); }
/** * @param array $row * @param Style $style */ public function addRow(array $row, Style $style = null) { if (!empty($row)) { $style = $style instanceof Style ? $style : $this->styler->getDefaultStyle(); $this->styler->addStyle($style); $this->sheetFile->fwrite($this->sheet->addRow($row, $style)); } }
public function testLock() { $styler = new Styler(); $style = new Style(); $unlockedFont = $style->getFont(); $unlockedFill = $style->getFill(); $unlockedBorder = $style->getBorder(); $styler->addStyle($style); $lockedFont = $style->getFont()->setColor('abcdef'); $this->assertEquals($unlockedFont, $style->getFont()); $this->assertNotEquals($unlockedFont, $lockedFont); $lockedFill = $style->setFillColor('abcdef'); $this->assertEquals($unlockedFill, $style->getFill()); $this->assertNotEquals($unlockedFill, $lockedFill); $lockedBorder = $style->setSurroundingBorder(); $this->assertEquals($unlockedBorder, $style->getBorder()); $this->assertNotEquals($unlockedBorder, $lockedBorder); }