From 6f7b97e3ab562c1dbabc05d5a06bff4a1e426e20 Mon Sep 17 00:00:00 2001 From: Ivan Lanin Date: Tue, 1 Apr 2014 19:05:07 +0700 Subject: [PATCH] Add unit tests for refactoring results --- src/PhpWord/DocumentProperties.php | 12 ++++++------ src/PhpWord/Media.php | 2 +- tests/PhpWord/Tests/FootnoteTest.php | 1 + tests/PhpWord/Tests/MediaTest.php | 2 ++ tests/PhpWord/Tests/SettingsTest.php | 12 +++++++++++- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 63ff0275..14ed3150 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -39,14 +39,14 @@ class DocumentProperties /** * Created * - * @var datetime|int + * @var int */ private $_created; /** * Modified * - * @var datetime|int + * @var int */ private $_modified; @@ -171,7 +171,7 @@ class DocumentProperties /** * Get Created * - * @return datetime + * @return int */ public function getCreated() { @@ -181,7 +181,7 @@ class DocumentProperties /** * Set Created * - * @param datetime $pValue + * @param int $pValue * @return \PhpOffice\PhpWord\DocumentProperties */ public function setCreated($pValue = null) @@ -196,7 +196,7 @@ class DocumentProperties /** * Get Modified * - * @return datetime + * @return int */ public function getModified() { @@ -206,7 +206,7 @@ class DocumentProperties /** * Set Modified * - * @param datetime $pValue + * @param int $pValue * @return \PhpOffice\PhpWord\DocumentProperties */ public function setModified($pValue = null) diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index c8b33301..dea9e1f3 100755 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -202,7 +202,7 @@ class Media if (!empty(self::$media)) { foreach (self::$media as $key => $val) { if (substr($key, 0, 6) == $prefix) { - $mediaCollection[$key] = $val; + $mediaCollection[$key] = $val; } } } diff --git a/tests/PhpWord/Tests/FootnoteTest.php b/tests/PhpWord/Tests/FootnoteTest.php index ff74e992..955d02e5 100644 --- a/tests/PhpWord/Tests/FootnoteTest.php +++ b/tests/PhpWord/Tests/FootnoteTest.php @@ -30,5 +30,6 @@ class FootnoteTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, $rIdFootnote); $this->assertEquals(1, $rIdLink); $this->assertEquals(1, count(Footnote::getFootnoteElements())); + $this->assertEquals(1, count(Footnote::getFootnoteLinkElements())); } } diff --git a/tests/PhpWord/Tests/MediaTest.php b/tests/PhpWord/Tests/MediaTest.php index 2d1434b3..a3e6ead5 100644 --- a/tests/PhpWord/Tests/MediaTest.php +++ b/tests/PhpWord/Tests/MediaTest.php @@ -102,6 +102,8 @@ class MediaTest extends \PHPUnit_Framework_TestCase Media::addHeaderMediaElement(1, $remote, new Image($remote)); $this->assertEquals(2, Media::countHeaderMediaElements('header1')); + $this->assertEquals(2, count(Media::getMediaElements('header1'))); + $this->assertFalse(Media::getMediaElements('header2')); } /** diff --git a/tests/PhpWord/Tests/SettingsTest.php b/tests/PhpWord/Tests/SettingsTest.php index 543da143..fa78489e 100644 --- a/tests/PhpWord/Tests/SettingsTest.php +++ b/tests/PhpWord/Tests/SettingsTest.php @@ -19,7 +19,7 @@ use PhpOffice\PhpWord\Settings; class SettingsTest extends \PHPUnit_Framework_TestCase { /** - * Get and set compatibity option + * Get/set compatibity option */ public function testGetSetCompatibility() { @@ -28,4 +28,14 @@ class SettingsTest extends \PHPUnit_Framework_TestCase $this->assertFalse(Settings::getCompatibility()); $this->assertFalse(Settings::setCompatibility('Non boolean')); } + + /** + * Get/set zip class + */ + public function testGetSetZipClass() + { + $this->assertEquals(Settings::ZIPARCHIVE, Settings::getZipClass()); + $this->assertTrue(Settings::setZipClass(Settings::PCLZIP)); + $this->assertFalse(Settings::setZipClass('foo')); + } }