Skip to content

Commit 141eb13

Browse files
committed
Renamed String class in Text class for supporting PHP7
1 parent e18d8cb commit 141eb13

File tree

5 files changed

+68
-63
lines changed

5 files changed

+68
-63
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ vendor
2222
/samples/#71
2323
/samples/Github_*.*
2424
/samples/#83/*.lnk
25+
/composer.lock

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
### Features
55
- Initial Release
66

7-
87
## 0.1.1
98

109
### Features
11-
- Added String::chr for suppporting Unicode Characters
10+
- Added String::chr for suppporting Unicode Characters
11+
12+
## 0.2.0
13+
14+
### Changes
15+
- Renamed String class in Text class for supporting PHP7
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
namespace PhpOffice\Common;
1818

1919
/**
20-
* String
20+
* Text
2121
*/
22-
class String
22+
class Text
2323
{
2424
/**
2525
* Control characters array

tests/Common/Tests/StringTest.php

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

tests/Common/Tests/TextTest.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* This file is part of PHPOffice Common
4+
*
5+
* PHPOffice Common is free software distributed under the terms of the GNU Lesser
6+
* General Public License version 3 as published by the Free Software Foundation.
7+
*
8+
* For the full copyright and license information, please read the LICENSE
9+
* file that was distributed with this source code. For the full list of
10+
* contributors, visit https://github.com/PHPOffice/Common/contributors.
11+
*
12+
* @link https://github.com/PHPOffice/Common
13+
* @copyright 2009-2014 PHPOffice Common contributors
14+
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
15+
*/
16+
17+
namespace PhpOffice\Common\Tests;
18+
19+
use PhpOffice\Common\Text;
20+
21+
/**
22+
* Test class for Text
23+
*
24+
* @coversDefaultClass PhpOffice\Common\Text
25+
*/
26+
class TextTest extends \PHPUnit_Framework_TestCase
27+
{
28+
/**
29+
*/
30+
public function testControlCharacters()
31+
{
32+
$this->assertEquals('', Text::controlCharacterPHP2OOXML());
33+
$this->assertEquals('aeiou', Text::controlCharacterPHP2OOXML('aeiou'));
34+
$this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù'));
35+
36+
$value = rand(0, 8);
37+
$this->assertEquals('_x'.sprintf('%04s', strtoupper(dechex($value))).'_', Text::controlCharacterPHP2OOXML(chr($value)));
38+
}
39+
40+
public function testNumberFormat()
41+
{
42+
$this->assertEquals('2.1', Text::numberFormat('2.06', 1));
43+
$this->assertEquals('2.1', Text::numberFormat('2.12', 1));
44+
$this->assertEquals('1234', Text::numberFormat(1234, 1));
45+
}
46+
47+
public function testChr()
48+
{
49+
$this->assertEquals('A', Text::chr(65));
50+
$this->assertEquals('A', Text::chr(0x41));
51+
$this->assertEquals('é', Text::chr(233));
52+
$this->assertEquals('é', Text::chr(0xE9));
53+
$this->assertEquals('', Text::chr(12083));
54+
$this->assertEquals('', Text::chr(0x2F33));
55+
$this->assertEquals('🌃', Text::chr(127747));
56+
$this->assertEquals('🌃', Text::chr(0x1F303));
57+
$this->assertEquals('', Text::chr(2097152));
58+
}
59+
}

0 commit comments

Comments
 (0)