File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -65,8 +65,10 @@ public function __construct($sectionCount, $style = null)
6565 {
6666 $ this ->sectionId = $ sectionCount ;
6767 $ this ->setDocPart ($ this ->container , $ this ->sectionId );
68- $ this ->style = new SectionStyle ();
69- $ this ->setStyle ($ style );
68+ if (null === $ style ) {
69+ $ style = new SectionStyle ();
70+ }
71+ $ this ->style = $ this ->setNewStyle (new SectionStyle (), $ style );
7072 }
7173
7274 /**
Original file line number Diff line number Diff line change 1919
2020use PhpOffice \PhpWord \PhpWord ;
2121use PhpOffice \PhpWord \Style ;
22+ use PhpOffice \PhpWord \Style \Section as SectionStyle ;
2223
2324/**
2425 * @covers \PhpOffice\PhpWord\Element\Section
2728 */
2829class SectionTest extends \PHPUnit \Framework \TestCase
2930{
31+ public function testConstructorWithDefaultStyle ()
32+ {
33+ $ section = new Section (0 );
34+ $ this ->assertInstanceOf ('PhpOffice \\PhpWord \\Style \\Section ' , $ section ->getStyle ());
35+ }
36+
37+ public function testConstructorWithArrayStyle ()
38+ {
39+ $ section = new Section (0 , array ('orientation ' => 'landscape ' ));
40+ $ style = $ section ->getStyle ();
41+ $ this ->assertInstanceOf ('PhpOffice \\PhpWord \\Style \\Section ' , $ style );
42+ $ this ->assertSame ('landscape ' , $ style ->getOrientation ());
43+ }
44+
45+ public function testConstorWithObjectStyle ()
46+ {
47+ $ style = new SectionStyle ();
48+ $ section = new Section (0 , $ style );
49+ $ this ->assertSame ($ style , $ section ->getStyle ());
50+ }
51+
3052 /**
3153 * @covers ::setStyle
3254 */
You can’t perform that action at this time.
0 commit comments