2014-03-10 13:29:48 +07:00
|
|
|
<?php
|
2014-03-27 23:55:06 +07:00
|
|
|
/**
|
2014-05-05 13:06:53 +04:00
|
|
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
|
|
|
|
* word processing documents.
|
|
|
|
|
*
|
|
|
|
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
|
|
|
|
* General Public License version 3 as published by the Free Software Foundation.
|
|
|
|
|
*
|
|
|
|
|
* For the full copyright and license information, please read the LICENSE
|
|
|
|
|
* file that was distributed with this source code. For the full list of
|
|
|
|
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
2014-03-27 23:55:06 +07:00
|
|
|
*
|
|
|
|
|
* @link https://github.com/PHPOffice/PHPWord
|
2015-12-05 21:25:59 +04:00
|
|
|
* @copyright 2010-2015 PHPWord contributors
|
2014-05-04 21:03:28 +04:00
|
|
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
2014-03-27 23:55:06 +07:00
|
|
|
*/
|
|
|
|
|
|
2015-11-15 13:33:05 +04:00
|
|
|
namespace PhpOffice\PhpWord\Shared;
|
2014-03-10 13:29:48 +07:00
|
|
|
|
|
|
|
|
/**
|
2014-03-27 23:55:06 +07:00
|
|
|
* Test class for PhpOffice\PhpWord\Shared\String
|
|
|
|
|
*
|
|
|
|
|
* @coversDefaultClass \PhpOffice\PhpWord\Shared\String
|
2014-03-10 13:29:48 +07:00
|
|
|
* @runTestsInSeparateProcesses
|
|
|
|
|
*/
|
|
|
|
|
class StringTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
2014-03-30 14:15:23 +07:00
|
|
|
/**
|
|
|
|
|
* Is UTF8
|
|
|
|
|
*/
|
2014-03-14 20:36:09 +01:00
|
|
|
public function testIsUTF8()
|
2014-03-10 13:29:48 +07:00
|
|
|
{
|
2014-03-23 17:37:26 +07:00
|
|
|
$this->assertTrue(String::isUTF8(''));
|
|
|
|
|
$this->assertTrue(String::isUTF8('éééé'));
|
|
|
|
|
$this->assertFalse(String::isUTF8(utf8_decode('éééé')));
|
2014-03-10 13:29:48 +07:00
|
|
|
}
|
|
|
|
|
|
2014-03-30 14:15:23 +07:00
|
|
|
/**
|
|
|
|
|
* OOXML to PHP control character
|
|
|
|
|
*/
|
2014-03-15 14:48:26 +07:00
|
|
|
public function testControlCharacterOOXML2PHP()
|
|
|
|
|
{
|
2014-03-23 17:37:26 +07:00
|
|
|
$this->assertEquals('', String::controlCharacterOOXML2PHP(''));
|
|
|
|
|
$this->assertEquals(chr(0x08), String::controlCharacterOOXML2PHP('_x0008_'));
|
2014-03-15 14:48:26 +07:00
|
|
|
}
|
2014-03-14 20:36:09 +01:00
|
|
|
|
2014-03-30 14:15:23 +07:00
|
|
|
/**
|
|
|
|
|
* PHP to OOXML control character
|
|
|
|
|
*/
|
2014-03-15 14:48:26 +07:00
|
|
|
public function testControlCharacterPHP2OOXML()
|
|
|
|
|
{
|
2014-03-23 17:37:26 +07:00
|
|
|
$this->assertEquals('', String::controlCharacterPHP2OOXML(''));
|
|
|
|
|
$this->assertEquals('_x0008_', String::controlCharacterPHP2OOXML(chr(0x08)));
|
2014-03-15 14:48:26 +07:00
|
|
|
}
|
2014-05-21 22:10:36 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test unicode conversion
|
|
|
|
|
*/
|
|
|
|
|
public function testToUnicode()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals('a', String::toUnicode('a'));
|
|
|
|
|
$this->assertEquals('\uc0{\u8364}', String::toUnicode('€'));
|
|
|
|
|
$this->assertEquals('\uc0{\u233}', String::toUnicode('é'));
|
|
|
|
|
}
|
2014-06-29 14:10:49 +07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test remove underscore prefix
|
|
|
|
|
*/
|
|
|
|
|
public function testRemoveUnderscorePrefix()
|
|
|
|
|
{
|
|
|
|
|
$this->assertEquals('item', String::removeUnderscorePrefix('_item'));
|
|
|
|
|
}
|
2014-03-23 17:37:26 +07:00
|
|
|
}
|