Skip to content

Commit b2a42e2

Browse files
committed
fix tests
1 parent bc0745f commit b2a42e2

File tree

4 files changed

+19
-106
lines changed

4 files changed

+19
-106
lines changed

src/PhpWord/Element/CheckBox.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ class CheckBox extends Text
3535
private $name;
3636

3737
/**
38-
* Default value
38+
* Default value.
3939
*
4040
* @var bool
4141
*/
4242
private $default = false;
4343

4444
/**
45-
* Create new instance
45+
* Create new instance.
4646
*
4747
* @param string $name
4848
* @param string $text
@@ -80,19 +80,19 @@ public function getName()
8080
}
8181

8282
/**
83-
* set default checked status
84-
* @param bool $default
83+
* set default checked status.
84+
*
8585
* @return CheckBox
8686
*/
8787
public function setDefault(bool $default = false)
8888
{
8989
$this->default = $default;
90+
9091
return $this;
9192
}
9293

9394
/**
94-
* get default checked status
95-
* @return bool
95+
* get default checked status.
9696
*/
9797
public function isDefault(): bool
9898
{

src/PhpWord/Writer/Word2007/Element/CheckBox.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function write(): void
5252
$xmlWriter->startElement('w:checkBox');
5353
$xmlWriter->writeAttribute('w:sizeAuto', '');
5454
$xmlWriter->startElement('w:default');
55-
$xmlWriter->writeAttribute('w:val', $element->getDefault() ? 1 : 0);
55+
$xmlWriter->writeAttribute('w:val', $element->isDefault() ? 1 : 0);
5656
$xmlWriter->endElement(); //w:default
5757
$xmlWriter->endElement(); //w:checkBox
5858
$xmlWriter->endElement(); // w:ffData

tests/PhpWord/Element/CheckBoxTest.php

Lines changed: 0 additions & 99 deletions
This file was deleted.

tests/PhpWordTests/Element/CheckBoxTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,16 @@ public function testParagraph(): void
8585
$oCheckBox->setParagraphStyle(['alignment' => Jc::CENTER, 'spaceAfter' => 100]);
8686
self::assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $oCheckBox->getParagraphStyle());
8787
}
88+
89+
/**
90+
* Get default value.
91+
*/
92+
public function testDefault(): void
93+
{
94+
$oCheckBox = new CheckBox('chkBox', 'CheckBox');
95+
self::assertFalse($oCheckBox->isDefault());
96+
97+
$oCheckBox->setDefault(true);
98+
self::assertTrue($oCheckBox->isDefault());
99+
}
88100
}

0 commit comments

Comments
 (0)