PHPWord/tests/PhpWord/Tests/Shared/StringTest.php

58 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2014-03-27 23:55:06 +07: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
* @copyright 2010-2014 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
*/
namespace PhpOffice\PhpWord\Tests\Shared;
use PhpOffice\PhpWord\Shared\String;
/**
2014-03-27 23:55:06 +07:00
* Test class for PhpOffice\PhpWord\Shared\String
*
* @coversDefaultClass \PhpOffice\PhpWord\Shared\String
* @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()
{
$this->assertTrue(String::isUTF8(''));
$this->assertTrue(String::isUTF8('éééé'));
$this->assertFalse(String::isUTF8(utf8_decode('éééé')));
}
2014-03-30 14:15:23 +07:00
/**
* OOXML to PHP control character
*/
public function testControlCharacterOOXML2PHP()
{
$this->assertEquals('', String::controlCharacterOOXML2PHP(''));
$this->assertEquals(chr(0x08), String::controlCharacterOOXML2PHP('_x0008_'));
}
2014-03-14 20:36:09 +01:00
2014-03-30 14:15:23 +07:00
/**
* PHP to OOXML control character
*/
public function testControlCharacterPHP2OOXML()
{
$this->assertEquals('', String::controlCharacterPHP2OOXML(''));
$this->assertEquals('_x0008_', String::controlCharacterPHP2OOXML(chr(0x08)));
}
}