Skip to content

Commit 4e546d1

Browse files
author
Roman Syroeshko
committed
#58 - Part IV.
1 parent 51ced7d commit 4e546d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+354
-431
lines changed

Classes/PHPWord/Reader/AbstractReader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
* @version 0.8.0
2626
*/
2727

28+
namespace PhpOffice\PhpWord\Reader;
29+
2830
use PhpOffice\PhpWord\Exceptions\Exception;
2931

3032
/**
31-
* PHPWord_Reader_Abstract
32-
*
33-
* @codeCoverageIgnore Abstract class
33+
* @codeCoverageIgnore Abstract class
3434
*/
35-
abstract class PHPWord_Reader_Abstract implements PHPWord_Reader_IReader
35+
abstract class AbstractReader implements IReader
3636
{
3737
/**
3838
* Read data only?
@@ -61,7 +61,7 @@ public function getReadDataOnly()
6161
* Set read data only
6262
*
6363
* @param bool $pValue
64-
* @return PHPWord_Reader_IReader
64+
* @return PhpOffice\PhpWord\Reader\IReader
6565
*/
6666
public function setReadDataOnly($pValue = true)
6767
{
@@ -91,7 +91,7 @@ protected function openFile($pFilename)
9191
}
9292

9393
/**
94-
* Can the current PHPWord_Reader_IReader read the file?
94+
* Can the current IReader read the file?
9595
*
9696
* @param string $pFilename
9797
* @return bool

Tests/PHPWord/SectionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ public function testAddElements()
107107
// 'Title', 'TextRun');
108108
// $i = 0;
109109
// foreach ($elementTypes as $elementType) {
110-
// $objectType = "PHPWord_Section_{$elementType}";
111-
// $this->assertInstanceOf($objectType, $elementCollection[$i]);
110+
// $this->assertInstanceOf("PhpOffice\\PhpWord\\Section\\{$elementType}", $elementCollection[$i]);
112111
// $i++;
113112
// }
114113
}

Tests/PHPWord/Shared/DrawingTest.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?php
22
namespace PHPWord\Tests\Shared;
33

4-
use PHPWord_Shared_Drawing;
4+
use PhpOffice\PhpWord\Shared\Drawing;
55

66
/**
7-
* Class DrawingTest
8-
*
97
* @package PHPWord\Tests
108
* @runTestsInSeparateProcesses
119
*/
@@ -21,28 +19,28 @@ public function testUnitConversions()
2119
$values[] = rand(1, 100); // integer
2220

2321
foreach ($values as $value) {
24-
$result = PHPWord_Shared_Drawing::pixelsToEMU($value);
22+
$result = Drawing::pixelsToEMU($value);
2523
$this->assertEquals(round($value * 9525), $result);
2624

27-
$result = PHPWord_Shared_Drawing::EMUToPixels($value);
25+
$result = Drawing::EMUToPixels($value);
2826
$this->assertEquals(round($value / 9525), $result);
2927

30-
$result = PHPWord_Shared_Drawing::pixelsToPoints($value);
28+
$result = Drawing::pixelsToPoints($value);
3129
$this->assertEquals($value * 0.67777777, $result);
3230

33-
$result = PHPWord_Shared_Drawing::pointsToPixels($value);
31+
$result = Drawing::pointsToPixels($value);
3432
$this->assertEquals($value * 1.333333333, $result);
3533

36-
$result = PHPWord_Shared_Drawing::degreesToAngle($value);
34+
$result = Drawing::degreesToAngle($value);
3735
$this->assertEquals((int)round($value * 60000), $result);
3836

39-
$result = PHPWord_Shared_Drawing::angleToDegrees($value);
37+
$result = Drawing::angleToDegrees($value);
4038
$this->assertEquals(round($value / 60000), $result);
4139

42-
$result = PHPWord_Shared_Drawing::pixelsToCentimeters($value);
40+
$result = Drawing::pixelsToCentimeters($value);
4341
$this->assertEquals($value * 0.028, $result);
4442

45-
$result = PHPWord_Shared_Drawing::centimetersToPixels($value);
43+
$result = Drawing::centimetersToPixels($value);
4644
$this->assertEquals($value / 0.028, $result);
4745
}
4846
}
@@ -59,8 +57,8 @@ public function testHtmlToRGB()
5957
$values[] = array('0F9D', false); // 4 characters
6058
// Conduct test
6159
foreach ($values as $value) {
62-
$result = PHPWord_Shared_Drawing::htmlToRGB($value[0]);
60+
$result = Drawing::htmlToRGB($value[0]);
6361
$this->assertEquals($value[1], $result);
6462
}
6563
}
66-
}
64+
}

Tests/PHPWord/Shared/FileTest.php

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<?php
22
namespace PHPWord\Tests\Shared;
33

4-
use PHPWord_Shared_File;
4+
use PhpOffice\PhpWord\Shared\File;
55

66
/**
7-
* Class FileTest
8-
*
9-
* @package PHPWord\Tests
10-
* @coversDefaultClass PHPWord_Shared_File
7+
* @package PHPWord\Tests
8+
* @coversDefaultClass PhpOffice\PhpWord\Shared\File
119
* @runTestsInSeparateProcesses
1210
*/
1311
class FileTest extends \PHPUnit_Framework_TestCase
@@ -17,41 +15,29 @@ class FileTest extends \PHPUnit_Framework_TestCase
1715
*/
1816
public function testFileExists()
1917
{
20-
$dir = join(DIRECTORY_SEPARATOR, array(
21-
PHPWORD_TESTS_DIR_ROOT,
22-
'_files',
23-
'templates'
24-
));
18+
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
2519
chdir($dir);
26-
$this->assertTrue(PHPWord_Shared_File::file_exists('blank.docx'));
20+
$this->assertTrue(File::file_exists('blank.docx'));
2721
}
2822
/**
2923
* Test file_exists()
3024
*/
3125
public function testNoFileExists()
3226
{
33-
$dir = join(DIRECTORY_SEPARATOR, array(
34-
PHPWORD_TESTS_DIR_ROOT,
35-
'_files',
36-
'templates'
37-
));
27+
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
3828
chdir($dir);
39-
$this->assertFalse(PHPWord_Shared_File::file_exists('404.docx'));
29+
$this->assertFalse(File::file_exists('404.docx'));
4030
}
4131

4232
/**
4333
* Test realpath()
4434
*/
4535
public function testRealpath()
4636
{
47-
$dir = join(DIRECTORY_SEPARATOR, array(
48-
PHPWORD_TESTS_DIR_ROOT,
49-
'_files',
50-
'templates'
51-
));
37+
$dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_DIR_ROOT, '_files', 'templates'));
5238
chdir($dir);
5339
$file = 'blank.docx';
5440
$expected = $dir . DIRECTORY_SEPARATOR . $file;
55-
$this->assertEquals($expected, PHPWord_Shared_File::realpath($file));
41+
$this->assertEquals($expected, File::realpath($file));
5642
}
57-
}
43+
}

Tests/PHPWord/Shared/FontTest.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
namespace PHPWord\Tests\Shared;
33

44
use PHPWord;
5-
use PHPWord_Shared_Font;
5+
use PhpOffice\PhpWord\Shared\Font;
66

77
/**
8-
* Class FontTest
9-
*
108
* @package PHPWord\Tests
119
* @runTestsInSeparateProcesses
1210
*/
@@ -21,25 +19,25 @@ public function testConversions()
2119

2220
$original = 1;
2321

24-
$result = PHPWord_Shared_Font::fontSizeToPixels($original);
22+
$result = Font::fontSizeToPixels($original);
2523
$this->assertEquals($original * 16 / 12, $result);
2624

27-
$result = PHPWord_Shared_Font::inchSizeToPixels($original);
25+
$result = Font::inchSizeToPixels($original);
2826
$this->assertEquals($original * 96, $result);
2927

30-
$result = PHPWord_Shared_Font::centimeterSizeToPixels($original);
28+
$result = Font::centimeterSizeToPixels($original);
3129
$this->assertEquals($original * 37.795275591, $result);
3230

33-
$result = PHPWord_Shared_Font::centimeterSizeToTwips($original);
31+
$result = Font::centimeterSizeToTwips($original);
3432
$this->assertEquals($original * 565.217, $result);
3533

36-
$result = PHPWord_Shared_Font::inchSizeToTwips($original);
34+
$result = Font::inchSizeToTwips($original);
3735
$this->assertEquals($original * 565.217 * 2.54, $result);
3836

39-
$result = PHPWord_Shared_Font::pixelSizeToTwips($original);
37+
$result = Font::pixelSizeToTwips($original);
4038
$this->assertEquals($original * 565.217 / 37.795275591, $result);
4139

42-
$result = PHPWord_Shared_Font::pointSizeToTwips($original);
40+
$result = Font::pointSizeToTwips($original);
4341
$this->assertEquals($original * 20, $result);
4442
}
45-
}
43+
}

Tests/PHPWord/Shared/StringTest.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
<?php
22
namespace PHPWord\Tests\Shared;
33

4-
use PHPWord_Shared_String;
4+
use PhpOffice\PhpWord\Shared\String;
55

66
/**
7-
* Class StringTest
8-
*
9-
* @package PHPWord\Tests
10-
* @coversDefaultClass PHPWord_Shared_String
7+
* @package PHPWord\Tests
8+
* @coversDefaultClass PhpOffice\PhpWord\Shared\String
119
* @runTestsInSeparateProcesses
1210
*/
1311
class StringTest extends \PHPUnit_Framework_TestCase
1412
{
1513
public function testIsUTF8()
1614
{
17-
$this->assertTrue(PHPWord_Shared_String::IsUTF8(''));
18-
$this->assertTrue(PHPWord_Shared_String::IsUTF8('éééé'));
19-
$this->assertFalse(PHPWord_Shared_String::IsUTF8(utf8_decode('éééé')));
15+
$this->assertTrue(String::IsUTF8(''));
16+
$this->assertTrue(String::IsUTF8('éééé'));
17+
$this->assertFalse(String::IsUTF8(utf8_decode('éééé')));
2018
}
2119

2220
public function testControlCharacterOOXML2PHP()
2321
{
24-
$this->assertEquals('', PHPWord_Shared_String::ControlCharacterOOXML2PHP(''));
25-
$this->assertEquals(chr(0x08), PHPWord_Shared_String::ControlCharacterOOXML2PHP('_x0008_'));
22+
$this->assertEquals('', String::ControlCharacterOOXML2PHP(''));
23+
$this->assertEquals(chr(0x08), String::ControlCharacterOOXML2PHP('_x0008_'));
2624
}
2725

2826
public function testControlCharacterPHP2OOXML()
2927
{
30-
$this->assertEquals('', PHPWord_Shared_String::ControlCharacterPHP2OOXML(''));
31-
$this->assertEquals('_x0008_', PHPWord_Shared_String::ControlCharacterPHP2OOXML(chr(0x08)));
28+
$this->assertEquals('', String::ControlCharacterPHP2OOXML(''));
29+
$this->assertEquals('_x0008_', String::ControlCharacterPHP2OOXML(chr(0x08)));
3230
}
33-
}
31+
}

Tests/PHPWord/Style/CellTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<?php
22
namespace PHPWord\Tests\Style;
33

4-
use PHPWord_Style_Cell;
4+
use PhpOffice\PhpWord\Style\Cell;
55

66
/**
7-
* Class CellTest
8-
*
97
* @package PHPWord\Tests
108
* @runTestsInSeparateProcesses
119
*/
@@ -16,11 +14,11 @@ class CellTest extends \PHPUnit_Framework_TestCase
1614
*/
1715
public function testSetGetNormal()
1816
{
19-
$object = new PHPWord_Style_Cell();
17+
$object = new Cell();
2018

2119
$attributes = array(
2220
'valign' => 'left',
23-
'textDirection' => PHPWord_Style_Cell::TEXT_DIR_BTLR,
21+
'textDirection' => Cell::TEXT_DIR_BTLR,
2422
'bgColor' => 'FFFF00',
2523
'borderTopSize' => 120,
2624
'borderTopColor' => 'FFFF00',
@@ -46,7 +44,7 @@ public function testSetGetNormal()
4644
*/
4745
public function testBorderColor()
4846
{
49-
$object = new PHPWord_Style_Cell();
47+
$object = new Cell();
5048

5149
$default = '000000';
5250
$value = 'FF0000';
@@ -66,11 +64,11 @@ public function testBorderColor()
6664
*/
6765
public function testBorderSize()
6866
{
69-
$object = new PHPWord_Style_Cell();
67+
$object = new Cell();
7068

7169
$value = 120;
7270
$expected = array($value, $value, $value, $value);
7371
$object->setStyleValue('_borderSize', $value);
7472
$this->assertEquals($expected, $object->getBorderSize());
7573
}
76-
}
74+
}

Tests/PHPWord/Style/FontTest.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
namespace PHPWord\Tests\Style;
33

44
use PHPWord;
5-
use PHPWord_Style_Font;
5+
use PhpOffice\PhpWord\Style\Font;
66
use PHPWord\Tests\TestHelperDOCX;
77

88
/**
9-
* Class FontTest
10-
*
119
* @package PHPWord\Tests
1210
* @runTestsInSeparateProcesses
1311
*/
@@ -23,18 +21,18 @@ public function tearDown()
2321
*/
2422
public function testInitiation()
2523
{
26-
$object = new PHPWord_Style_Font('text', array('align' => 'both'));
24+
$object = new Font('text', array('align' => 'both'));
2725

2826
$this->assertEquals('text', $object->getStyleType());
29-
$this->assertInstanceOf('PHPWord_Style_Paragraph', $object->getParagraphStyle());
27+
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
3028
}
3129

3230
/**
3331
* Test setting style values with null or empty value
3432
*/
3533
public function testSetStyleValueWithNullOrEmpty()
3634
{
37-
$object = new PHPWord_Style_Font();
35+
$object = new Font();
3836

3937
$attributes = array(
4038
'name' => PHPWord::DEFAULT_FONT_NAME,
@@ -43,7 +41,7 @@ public function testSetStyleValueWithNullOrEmpty()
4341
'italic' => false,
4442
'superScript' => false,
4543
'subScript' => false,
46-
'underline' => PHPWord_Style_Font::UNDERLINE_NONE,
44+
'underline' => Font::UNDERLINE_NONE,
4745
'strikethrough' => false,
4846
'color' => PHPWord::DEFAULT_FONT_COLOR,
4947
'fgColor' => null,
@@ -62,7 +60,7 @@ public function testSetStyleValueWithNullOrEmpty()
6260
*/
6361
public function testSetStyleValueNormal()
6462
{
65-
$object = new PHPWord_Style_Font();
63+
$object = new Font();
6664

6765
$attributes = array(
6866
'name' => 'Times New Roman',
@@ -71,7 +69,7 @@ public function testSetStyleValueNormal()
7169
'italic' => true,
7270
'superScript' => true,
7371
'subScript' => true,
74-
'underline' => PHPWord_Style_Font::UNDERLINE_HEAVY,
72+
'underline' => Font::UNDERLINE_HEAVY,
7573
'strikethrough' => true,
7674
'color' => '999999',
7775
'fgColor' => '999999',
@@ -113,4 +111,4 @@ public function testLineHeight()
113111
$this->assertEquals(720, $lineHeight);
114112
$this->assertEquals('auto', $lineRule);
115113
}
116-
}
114+
}

0 commit comments

Comments
 (0)