77/**
88 * Class ODTextTest
99 *
10- * @package PHPWord\Tests
10+ * @package PHPWord\Tests
11+ * @coversDefaultClass PHPWord_Writer_ODText
1112 * @runTestsInSeparateProcesses
1213 */
1314class ODTextTest extends \PHPUnit_Framework_TestCase
@@ -37,10 +38,9 @@ public function testConstruct()
3738 }
3839
3940 /**
40- * Test construct with null value/without PHPWord
41- *
42- * @expectedException Exception
43- * @expectedExceptionMessage No PHPWord assigned.
41+ * @covers ::getPHPWord
42+ * @expectedException Exception
43+ * @expectedExceptionMessage No PHPWord assigned.
4444 */
4545 public function testConstructWithNull ()
4646 {
@@ -49,39 +49,106 @@ public function testConstructWithNull()
4949 }
5050
5151 /**
52- * Test save()
52+ * @covers :: save
5353 */
5454 public function testSave ()
5555 {
56+ $ imageSrc = \join (
57+ \DIRECTORY_SEPARATOR ,
58+ array (\PHPWORD_TESTS_DIR_ROOT , '_files ' , 'images ' , 'PHPWord.png ' )
59+ );
60+ $ objectSrc = \join (
61+ \DIRECTORY_SEPARATOR ,
62+ array (\PHPWORD_TESTS_DIR_ROOT , '_files ' , 'documents ' , 'sheet.xls ' )
63+ );
64+ $ file = \join (
65+ \DIRECTORY_SEPARATOR ,
66+ array (\PHPWORD_TESTS_DIR_ROOT , '_files ' , 'temp.odt ' )
67+ );
68+
5669 $ phpWord = new PHPWord ();
5770 $ phpWord ->addFontStyle ('Font ' , array ('size ' => 11 ));
5871 $ phpWord ->addParagraphStyle ('Paragraph ' , array ('align ' => 'center ' ));
5972 $ section = $ phpWord ->createSection ();
60- $ section ->addText ('Test 1 ' , 'Font ' , ' Paragraph ' );
73+ $ section ->addText ('Test 1 ' , 'Font ' );
6174 $ section ->addTextBreak ();
62- $ section ->addText ('Test 2 ' );
75+ $ section ->addText ('Test 2 ' , null , 'Paragraph ' );
76+ $ section ->addLink ('http://test.com ' );
77+ $ section ->addTitle ('Test ' , 1 );
78+ $ section ->addPageBreak ();
79+ $ section ->addTable ();
80+ $ section ->addListItem ('Test ' );
81+ $ section ->addImage ($ imageSrc );
82+ $ section ->addObject ($ objectSrc );
83+ $ section ->addTOC ();
6384 $ section = $ phpWord ->createSection ();
6485 $ textrun = $ section ->createTextRun ();
6586 $ textrun ->addText ('Test 3 ' );
66-
6787 $ writer = new PHPWord_Writer_ODText ($ phpWord );
68- $ file = join (
69- DIRECTORY_SEPARATOR ,
70- array (PHPWORD_TESTS_DIR_ROOT , '_files ' , 'temp.odt ' )
71- );
7288 $ writer ->save ($ file );
89+
7390 $ this ->assertTrue (file_exists ($ file ));
91+
7492 unlink ($ file );
7593 }
7694
7795 /**
78- * Test disk caching parameters
96+ * @covers ::save
97+ * @todo Haven't got any method to test this
98+ */
99+ public function testSavePhpOutput ()
100+ {
101+ $ phpWord = new PHPWord ();
102+ $ section = $ phpWord ->createSection ();
103+ $ section ->addText ('Test ' );
104+ $ writer = new PHPWord_Writer_ODText ($ phpWord );
105+ $ writer ->save ('php://output ' );
106+ }
107+
108+ /**
109+ * @covers ::save
110+ * @expectedException Exception
111+ * @expectedExceptionMessage PHPWord object unassigned.
112+ */
113+ public function testSaveException ()
114+ {
115+ $ writer = new PHPWord_Writer_ODText ();
116+ $ writer ->save ();
117+ }
118+
119+ /**
120+ * @covers ::getWriterPart
79121 */
80- public function testSetDiskCaching ()
122+ public function testGetWriterPartNull ()
123+ {
124+ $ object = new PHPWord_Writer_ODText ();
125+ $ this ->assertNull ($ object ->getWriterPart ('foo ' ));
126+ }
127+
128+ /**
129+ * @covers ::setUseDiskCaching
130+ * @covers ::getUseDiskCaching
131+ */
132+ public function testSetGetUseDiskCaching ()
81133 {
82134 $ object = new PHPWord_Writer_ODText ();
83135 $ object ->setUseDiskCaching (true , PHPWORD_TESTS_DIR_ROOT );
84136 $ this ->assertTrue ($ object ->getUseDiskCaching ());
85137 $ this ->assertEquals (PHPWORD_TESTS_DIR_ROOT , $ object ->getDiskCachingDirectory ());
86138 }
139+
140+ /**
141+ * @covers ::setUseDiskCaching
142+ * @expectedException Exception
143+ */
144+ public function testSetUseDiskCachingException ()
145+ {
146+ $ dir = \join (
147+ \DIRECTORY_SEPARATOR ,
148+ array (\PHPWORD_TESTS_DIR_ROOT , 'foo ' )
149+ );
150+
151+ $ object = new PHPWord_Writer_ODText ($ phpWord );
152+ $ object ->setUseDiskCaching (true , $ dir );
153+ }
87154}
0 commit comments