setConditionType(Conditional::CONDITION_ICONSET); $iconSet = $condition->setIconSet(new ConditionalIconSet()) ->getIconSet(); self::assertNotNull($iconSet); if ($type !== null) { $iconSet->setIconSetType($type); } $iconSet->setCfvos([ new ConditionalFormatValueObject('percent', 0), new ConditionalFormatValueObject('percent', 33), new ConditionalFormatValueObject('percent', 67), ]); if ($reverse !== null) { $iconSet->setReverse($reverse); } if ($showValue !== null) { $iconSet->setShowValue($showValue); } if ($custom !== null) { $iconSet->setCustom($custom); } $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); $worksheet->setConditionalStyles(self::COORDINATE, [$condition]); $writer = new Xlsx($spreadsheet); $writerWorksheet = new Xlsx\Worksheet($writer); $data = $writerWorksheet->writeWorksheet($worksheet, []); $expected = preg_replace(['/^\s+/m', "/\n/"], '', $expected); self::assertIsString($expected); self::assertStringContainsString($expected, $data); } public static function iconSetsProvider(): Generator { $coordinate = self::COORDINATE; $cfvos = << XML; foreach (IconSetValues::cases() as $type) { yield $type->name => [ << {$cfvos} XML, $type, ]; } yield 'null' => [ << {$cfvos} XML, null, ]; foreach ([1, 0] as $reverse) { yield "null/reverse=$reverse" => [ << {$cfvos} XML, null, $reverse === 1, ]; } foreach ([1, 0] as $showValue) { yield "null/showValue=$showValue" => [ << {$cfvos} XML, null, null, $showValue === 1, ]; } foreach ([1, 0] as $custom) { yield "null/custom=$custom" => [ << {$cfvos} XML, null, null, null, $custom === 1, ]; } } }